MFF

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

    NBTTag et IIcon

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    21 Messages 3 Publieurs 3.7k 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.
    • robin4002R Hors-ligne
      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
      dernière édition par

      Il faut utiliser
      public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
      pour mettre la texture dans le tile entity.

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

        La texture ne s’applique pas
        Block:
        :::

        package virusz.block;
        
        import net.minecraft.block.Block;
        import net.minecraft.block.material.Material;
        import net.minecraft.entity.Entity;
        import net.minecraft.entity.player.EntityPlayer;
        import net.minecraft.item.ItemBlock;
        import net.minecraft.nbt.NBTTagCompound;
        import net.minecraft.tileentity.TileEntity;
        import net.minecraft.util.ChatComponentText;
        import net.minecraft.util.ChatComponentTranslation;
        import net.minecraft.util.EnumChatFormatting;
        import net.minecraft.util.IIcon;
        import net.minecraft.world.World;
        
        import org.lwjgl.input.Keyboard;
        
        import cpw.mods.fml.relauncher.Side;
        import cpw.mods.fml.relauncher.SideOnly;
        import virusz.core.VirusZCore;
        import virusz.tileEntity.TileEntitySafeZone;
        
        public class BlockSafeZone extends Block
        {
        private String State = "nothing";
        public BlockSafeZone(Material par2Material)
        {
        super(par2Material);
        this.setBlockUnbreakable();
        this.setCreativeTab(VirusZCore.Blocks);
        }
        
        @Override
           public boolean isOpaqueCube()
           {
               return false;
           }
        
           @Override
           public boolean renderAsNormalBlock()
           {
               return false;
           }  
           @Override
           public TileEntity createTileEntity(World world, int metadata)
           {
               return new TileEntitySafeZone();
           }
        
           @Override
           public boolean hasTileEntity(int metadata)
           {
               return true;
           }
           @Override
           public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
           {
                   TileEntity tile = world.getTileEntity(x, y, z);
                   TileEntitySafeZone Tile = (TileEntitySafeZone)tile;
        
           if (!world.isRemote){
        
            if(player.isSneaking()){
            Tile.IncreaseState();
        
                if(Tile.GetState() == 0){
                this.State = "left";
                }
                if(Tile.GetState() == 1){
                this.State = "up";
                }
                if(Tile.GetState() == 2){
                this.State = "Down";
                }
                if(Tile.GetState() == 3){
                this.State = "Right";
                }
                if(Tile.GetState() == 4){
                this.State = "nothing";
                }
            player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "State set to: " + State + Tile.GetState()));
            }else if(player.getHeldItem() == null){
            Tile.IncreaseRadius();
            player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "radius set to: " + Tile.GetRadius() + " block"));
            }
            //get texture
              else if (player.getHeldItem().getItem() instanceof ItemBlock) {
              Tile.GetTextureData();
                 return true;
              }
            }
        
        return true;
        }
        
           @Override
           public void onEntityWalking(World world, int x, int y, int z, Entity entity){
                   EntityPlayer player = (EntityPlayer)entity;
                   TileEntity tile = world.getTileEntity(x, y, z);
                   TileEntitySafeZone Tile = (TileEntitySafeZone)tile;
        
            double X = entity.posX;
            double Y = entity.posY;
            double Z = entity.posZ;
            double RADIUS = Tile.GetRadius();
            System.out.println("OnWalking" + Tile.GetState());
        
            if(Tile.GetState() == 0){
            player.setPosition(X-RADIUS, Y, Z);
            }
            if(Tile.GetState() == 1){
            player.setPosition(X, Y, Z-RADIUS);
            }
            if(Tile.GetState() == 2){
            player.setPosition(X, Y, Z+RADIUS);
            }
            if(Tile.GetState() == 3){
            player.setPosition(X+RADIUS, Y, Z);
            }
        
           }
        }
        
        

        :::
        tile Entity
        :::

        package virusz.tileEntity;
        
        import net.minecraft.client.Minecraft;
        import net.minecraft.entity.player.EntityPlayer;
        import net.minecraft.nbt.NBTTagCompound;
        import net.minecraft.network.NetworkManager;
        import net.minecraft.network.Packet;
        import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
        import net.minecraft.tileentity.TileEntity;
        import net.minecraft.util.IIcon;
        import net.minecraft.world.IBlockAccess;
        
        public class TileEntitySafeZone extends TileEntity {
        
        private double radius = 5;
        private int state;
        private IIcon camouflageIcon;
        
           public void IncreaseState(){
            if(state > 3){
            state = state-4;
            }else{
            state++;
            }
               this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
           }
           public int GetState(){
            return state;
           }
           public void IncreaseRadius(){
            if(radius > 60){
            radius = radius-60;
            }else{
            radius = radius+5;
            }
               this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
           }
           public Double GetRadius(){
            return radius;
           }
           @Override
           public void writeToNBT(NBTTagCompound compound)
           {
               super.writeToNBT(compound);
               compound.setInteger("state", this.state);
               compound.setDouble("radius", radius);
           }
           @Override
           public void readFromNBT(NBTTagCompound compound)
           {
               super.readFromNBT(compound);
               this.state = compound.getInteger("state");
               this.radius = compound.getDouble("radius");
           }
        public Packet getDescriptionPacket()
        {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        this.writeToNBT(nbttagcompound);
        return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound);
        }
        
        public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
        {
        this.readFromNBT(pkt.func_148857_g());
        }
        
        public void GetTextureData(){
        EntityPlayer player = Minecraft.getMinecraft().thePlayer;
             camouflageIcon = player.getHeldItem().getIconIndex();
             System.out.println(camouflageIcon+"test");
        }
        public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
        return camouflageIcon;
        }
        }
        
        

        :::

        “Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire wo…

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

          La méthode getIcon est sur le block, pas la tileEntity

          Site web contenant mes scripts : http://SCAREXgaming.github.io

          Pas de demandes de support par MP ni par skype SVP.
          Je n'accepte sur skype que l…

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

            Si je set dans le block tout les bloc ont le même texture mon but c est que chaque block puisse être texturé différemment
            reprend moi si je dit une connerie xD

            “Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire wo…

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

              Hein ? Une classe par block, après tu peux utiliser les metadatas, mais c’est une classe par block

              Site web contenant mes scripts : http://SCAREXgaming.github.io

              Pas de demandes de support par MP ni par skype SVP.
              Je n'accepte sur skype que l…

              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

                Tu mets :
                public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
                Dans le bloc. Dans cette fonction tu as world, x, y et z donc tu peux récupérer le tile entity, et l’icône qui se trouve dans le tile entity.

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

                  Edit: Robin viens de répondre xD

                  je doit faire quelque choses dans le genre je suppose mais ça fonctionne pas

                  @Override
                  public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
                  TileEntity tile = world.getTileEntity(x, y, z);
                  TileEntitySafeZone Tile = (TileEntitySafeZone)tile;
                  return Tile.getIIcon();
                  }
                  
                  
                  public IIcon getIIcon(){
                  return camouflageIcon;
                  }
                  
                  

                  “Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire wo…

                  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

                    camouflageIcon est une variable static ou non ?

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

                      Non elle est pas static

                      “Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire wo…

                      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

                        ça devrait fonctionner alors.
                        Envois tout ton code actuel.

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

                          en la passant static ça fonctionne" mais tout les bloc récupère la texture alors que je voudrait que chaque instance ai sa propre texture

                          :::

                          package virusz.tileEntity;
                          
                          import net.minecraft.client.Minecraft;
                          import net.minecraft.entity.player.EntityPlayer;
                          import net.minecraft.nbt.NBTTagCompound;
                          import net.minecraft.network.NetworkManager;
                          import net.minecraft.network.Packet;
                          import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
                          import net.minecraft.tileentity.TileEntity;
                          import net.minecraft.util.IIcon;
                          import net.minecraft.world.IBlockAccess;
                          
                          public class TileEntitySafeZone extends TileEntity {
                          
                          private double radius = 5;
                          private int state;
                          private static IIcon camouflageIcon;
                          
                          public void IncreaseState(){
                          if(state > 3){
                          state = state-4;
                          }else{
                          state++;
                          }
                          this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
                          }
                          public int GetState(){
                          return state;
                          }
                          public void IncreaseRadius(){
                          if(radius > 60){
                          radius = radius-60;
                          }else{
                          radius = radius+5;
                          }
                          this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
                          }
                          public Double GetRadius(){
                          return radius;
                          }
                          @Override
                          public void writeToNBT(NBTTagCompound compound)
                          {
                          super.writeToNBT(compound);
                          compound.setInteger("state", this.state);
                          compound.setDouble("radius", radius);
                          }
                          @Override
                          public void readFromNBT(NBTTagCompound compound)
                          {
                          super.readFromNBT(compound);
                          this.state = compound.getInteger("state");
                          this.radius = compound.getDouble("radius");
                          }
                          public Packet getDescriptionPacket()
                          {
                          NBTTagCompound nbttagcompound = new NBTTagCompound();
                          this.writeToNBT(nbttagcompound);
                          return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound);
                          }
                          
                          public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
                          {
                          this.readFromNBT(pkt.func_148857_g());
                          }
                          
                          public void GetTextureData(){
                          EntityPlayer player = Minecraft.getMinecraft().thePlayer;
                          camouflageIcon = player.getHeldItem().getIconIndex();
                          System.out.println(camouflageIcon+"test");
                          }
                          public IIcon getIIcon(){
                          return camouflageIcon;
                          }
                          }
                          
                          

                          :::

                          :::

                          package virusz.block;
                          
                          import net.minecraft.block.Block;
                          import net.minecraft.block.material.Material;
                          import net.minecraft.entity.Entity;
                          import net.minecraft.entity.player.EntityPlayer;
                          import net.minecraft.item.ItemBlock;
                          import net.minecraft.nbt.NBTTagCompound;
                          import net.minecraft.tileentity.TileEntity;
                          import net.minecraft.util.ChatComponentText;
                          import net.minecraft.util.ChatComponentTranslation;
                          import net.minecraft.util.EnumChatFormatting;
                          import net.minecraft.util.IIcon;
                          import net.minecraft.world.IBlockAccess;
                          import net.minecraft.world.World;
                          
                          import org.lwjgl.input.Keyboard;
                          
                          import cpw.mods.fml.relauncher.Side;
                          import cpw.mods.fml.relauncher.SideOnly;
                          import virusz.core.VirusZCore;
                          import virusz.tileEntity.TileEntitySafeZone;
                          
                          public class BlockSafeZone extends Block
                          {
                          private String State = "nothing";
                          public BlockSafeZone(Material par2Material)
                          {
                          super(par2Material);
                          this.setBlockUnbreakable();
                          this.setCreativeTab(VirusZCore.Blocks);
                          }
                          
                          @Override
                          public boolean isOpaqueCube()
                          {
                          return false;
                          }
                          
                          @Override
                          public boolean renderAsNormalBlock()
                          {
                          return false;
                          }
                          @Override
                          public TileEntity createTileEntity(World world, int metadata)
                          {
                          return new TileEntitySafeZone();
                          }
                          
                          @Override
                          public boolean hasTileEntity(int metadata)
                          {
                          return true;
                          }
                          @Override
                          public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
                          {
                          TileEntity tile = world.getTileEntity(x, y, z);
                          TileEntitySafeZone Tile = (TileEntitySafeZone)tile;
                          
                          if (!world.isRemote){
                          
                          if(player.isSneaking()){
                          Tile.IncreaseState();
                          
                          if(Tile.GetState() == 0){
                          this.State = "left";
                          }
                          if(Tile.GetState() == 1){
                          this.State = "up";
                          }
                          if(Tile.GetState() == 2){
                          this.State = "Down";
                          }
                          if(Tile.GetState() == 3){
                          this.State = "Right";
                          }
                          if(Tile.GetState() == 4){
                          this.State = "nothing";
                          }
                          player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "State set to: " + State + Tile.GetState()));
                          }else if(player.getHeldItem() == null){
                          Tile.IncreaseRadius();
                          player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "radius set to: " + Tile.GetRadius() + " block"));
                          }
                          //get texture
                          else if (player.getHeldItem().getItem() instanceof ItemBlock) {
                          Tile.GetTextureData();
                          return true;
                          }
                          }
                          
                          return true;
                          }
                          @Override
                          public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
                          TileEntity tile = world.getTileEntity(x, y, z);
                          TileEntitySafeZone Tile = (TileEntitySafeZone)tile;
                          return Tile.getIIcon();
                          }
                          
                          @Override
                          public void onEntityWalking(World world, int x, int y, int z, Entity entity){
                          EntityPlayer player = (EntityPlayer)entity;
                          TileEntity tile = world.getTileEntity(x, y, z);
                          TileEntitySafeZone Tile = (TileEntitySafeZone)tile;
                          
                          double X = entity.posX;
                          double Y = entity.posY;
                          double Z = entity.posZ;
                          double RADIUS = Tile.GetRadius();
                          System.out.println("OnWalking" + Tile.GetState());
                          
                          if(Tile.GetState() == 0){
                          player.setPosition(X-RADIUS, Y, Z);
                          }
                          if(Tile.GetState() == 1){
                          player.setPosition(X, Y, Z-RADIUS);
                          }
                          if(Tile.GetState() == 2){
                          player.setPosition(X, Y, Z+RADIUS);
                          }
                          if(Tile.GetState() == 3){
                          player.setPosition(X+RADIUS, Y, Z);
                          }
                          
                          }
                          }
                          
                          

                          :::

                          “Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire wo…

                          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

                            La variable ne doit pas être static.
                            Utiliser :
                            public void GetTextureData(){
                            EntityPlayer player = Minecraft.getMinecraft().thePlayer;
                            camouflageIcon = player.getHeldItem().getIconIndex();
                            Minecraft.getMinecraft() ici n’est pas du tout une bonne idée.

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

                              Edit:j’ai trouver

                              j’ai fait ca:

                              public class BlockSafeZone extends Block
                              {
                              EntityPlayer player;
                              

                              tellement l’habitude de tout faire avec des var local que j’avait oublier que on pouvait faire ca mais ca change pas le probleme si je passe le IIcon en static ça fonctionne mais en non static ça ne fonctionne pas :c

                              “Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire wo…

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

                                et la texture est appliquer a tout les bloc sur le monde

                                “Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire wo…

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

                                  Personne a une idée?

                                  “Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire wo…

                                  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

                                    https://github.com/FFMT/Privatizer/blob/master/privatizer_src/fr/mcnanotech/privatizer/common/TileEntityPrivateAdaptable.java
                                    https://github.com/FFMT/Privatizer/blob/master/privatizer_src/fr/mcnanotech/privatizer/common/BlockPrivate.java#L156
                                    https://github.com/FFMT/Privatizer/blob/master/privatizer_src/fr/mcnanotech/privatizer/common/BlockPrivate.java#L288-L299

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

                                      je vois pas comment ca peut m’aider si je comprend bien c’est un bloc que tu peut private mais ce que j ai vu aussi c’est que tu register les textures en manuel si je fait ca je vais un peu galérer sachant que je veut pas utiliser uniquement quelques bloc mais bien tout les blocks du jeu après j’ai juste survolé le code je lis ça plus en détail pour vois mais si je doit créé une metadata+une texture par block présent dans minecraft je pense que le bloc risque d’être un peu lourd

                                      “Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire wo…

                                      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

                                        C’est un bloc qui change de texture lorsque tu fais un clic droit dessus avec un autre bloc. Peu-importe le quel c’est.
                                        Ne te soucis pas des metadatas, c’est parce qu’il y a d’autres blocs.

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

                                          Je regarde ça demain je suis trop crever pour réfléchir a demain je vous retient au courant

                                          “Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire wo…

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

                                            Merci ca fonctionne parfaitement merci encore pour votre aide

                                            “Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire wo…

                                            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