MFF

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

    [1.7]Problèmes textures sur une table

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    28 Messages 5 Publieurs 4.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.
    • Y Hors-ligne
      yohannlog
      dernière édition par

      
      @Mod(modid = Machines.MODID, version = Machines.VERSION)
      public class Machines
      {
      public static final String MODID = "machines";
      public static final String VERSION = "1.0";
      
      @Instance(MODID)
      public static Machines instance;
      
      @SidedProxy(clientSide = "fr.yohannlog.machinesplus.ClientProxy", serverSide = "fr.yohannlog.machinesplus.CommonProxy")
      public static CommonProxy proxy;
      
      public static Block BlockTable;
      public static Block BlockRuby;
      
      public static Item Glass, Gourde, GourdeFull; // Verre
      
      @EventHandler
      public void preInit(FMLPreInitializationEvent event)
      {
      BlockTable = new BlockTable(Material.wood).setBlockName("blocktable").setCreativeTab(CreativeTabs.tabBlock);
      BlockRuby = new BlockRuby (15000, Material.rock).setBlockName("BlockRuby").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName("machines:BlockRuby");
      
      Gourde = new Gourde().setFull3D().setMaxStackSize(1).setUnlocalizedName("Gourde_vide").setTextureName("machines:gourde_vide");
      GourdeFull = new GourdeFull().setFull3D().setUnlocalizedName("Gourde_Full").setTextureName("machines:Gourde_Full");
      GameRegistry.registerItem(Gourde, "Gourde");
      GameRegistry.registerItem(GourdeFull, "Gourde_Full");
      
      GameRegistry.registerBlock(BlockTable, "blocktable");
      GameRegistry.registerBlock(BlockRuby, "BlockRuby");
      }
      
      @EventHandler
      public void init(FMLInitializationEvent event)
      {
      
      proxy.registerRender();
      proxy.registerTileEntityRender();
      GameRegistry.registerTileEntity(TileEntityTable.class, "blocktable");
      }
      
      @EventHandler
      public void postInit(FMLPostInitializationEvent event)
      {
      
      }
      }
      
      

      BlockTable:

      
      public class BlockTable extends Block
      {
      
      public BlockTable(Material material)
      {
      super(material);
      }
      
      public TileEntity createTileEntity(World world, int metadata)
      {
      return new TileEntityTable();
      }
      
      public boolean hasTileEntity(int metadata)
      {
      return true;
      }
      
      public boolean renderAsNormalBlock()
      {
      return false;
      }
      
      public boolean isOpaqueCube()
      {
      return false;
      }
      
      @SideOnly(Side.CLIENT)
      public int getRenderType()
      {
      return ClientProxy.renderInventoryTable;
      }
      
      

      TileEntityTable:

      
      public class TileEntityTable extends TileEntity
      {
      public byte direction;
      
      public void readFromNBT(NBTTagCompound nbtTag)
      {
      super.readFromNBT(nbtTag);
      direction = nbtTag.getByte("direction");
      }
      
      public void writeToNBT(NBTTagCompound nbtTag)
      {
      nbtTag.setByte("direction", direction);
      }
      
      public void setDirection(byte direct)
      {
      direction = direct;
      }
      
      public byte getDirection()
      {
      return direction;
      }
      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());
      this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord);
      }
      }
      
      

      ModelTable

      
      public class ModelTable extends ModelBase
      {
      //fields
      ModelRenderer Shape1;
      ModelRenderer Shape2;
      
      public ModelTable()
      {
      textureWidth = 32;
      textureHeight = 32;
      
      Shape1 = new ModelRenderer(this, 0, 0);
      Shape1.addBox(0F, 0F, 0F, 2, 13, 2);
      Shape1.setRotationPoint(-1F, 11F, 0F);
      Shape1.setTextureSize(32, 32);
      Shape1.mirror = true;
      setRotation(Shape1, 0F, 0F, 0F);
      Shape2 = new ModelRenderer(this, 0, 0);
      Shape2.addBox(-6F, -1F, -5F, 13, 1, 12);
      Shape2.setRotationPoint(0F, 11F, 0F);
      Shape2.setTextureSize(32, 32);
      Shape2.mirror = true;
      setRotation(Shape2, 0F, 0F, 0F);
      }
      
      public void render(float f)
      {
      Shape1.render(f);
      Shape2.render(f);
      }
      
      private void setRotation(ModelRenderer model, float x, float y, float z)
      {
      model.rotateAngleX = x;
      model.rotateAngleY = y;
      model.rotateAngleZ = z;
      }
      
      }
      
      

      TableInventoryRenderer:

      
      public class TableInventoryRenderer implements ISimpleBlockRenderingHandler
      {
      public static class TESRIndex
      {
      Block block;
      int metadata;
      
      public TESRIndex(Block block, int metadata)
      {
      this.block = block;
      this.metadata = metadata;
      }
      
      @Override
      public int hashCode()
      {
      return block.hashCode() + metadata;
      }
      
      @Override
      public boolean equals(Object o)
      {
      if(!(o instanceof TESRIndex))
      return false;
      
      TESRIndex tesr = (TESRIndex)o;
      
      return tesr.block == block && tesr.metadata == metadata;
      }
      }
      
      public static HashMap <tesrindex, iinventoryrenderer="">blockByTESR = new HashMap<tesrindex, iinventoryrenderer="">();
      @Override
      public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer)
      {
      TESRIndex index = new TESRIndex(block, metadata);
      if(blockByTESR.containsKey(index))
      {
      blockByTESR.get(index).renderInventory(-0.5, -0.5, -0.5);
      }
      
      }
      
      @Override
      public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
      {
      return true;
      }
      
      public boolean shouldRender3DInInventory(int modelId)
      {
      // TODO Auto-generated method stub
      return true;
      }
      
      @Override
      public int getRenderId()
      {
      return ClientProxy.renderInventoryTable;
      }
      
      }
      
      

      TileEntityTable:

      
      public class TileEntityTable extends TileEntity
      {
      public byte direction;
      
      public void readFromNBT(NBTTagCompound nbtTag)
      {
      super.readFromNBT(nbtTag);
      direction = nbtTag.getByte("direction");
      }
      
      public void writeToNBT(NBTTagCompound nbtTag)
      {
      nbtTag.setByte("direction", direction);
      }
      
      public void setDirection(byte direct)
      {
      direction = direct;
      }
      
      public byte getDirection()
      {
      return direction;
      }
      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());
      this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord);
      }
      }
      
      

      TileEntityTableSpecialRenderer:

      
      public class TileEntityTableSpecialRender extends TileEntitySpecialRenderer implements IInventoryRenderer {
      public static final ResourceLocation textureLocation = new ResourceLocation(Machines.MODID, "textures/blocks/blocktable.png");
      private final ModelTable model = new ModelTable();
      
      public TileEntityTableSpecialRender()
      {
      this.func_147497_a(TileEntityRendererDispatcher.instance);
      }
      
      @Override
      public void renderInventory(double x, double y, double z)
      {
      this.renderTileEntityTableAt(null, x, y, z, 0.0F);
      }
      
      @Override
      public void renderTileEntityAt(TileEntity te, double x, double y, double z, float tick)
      {
      this.renderTileEntityTableAt((TileEntityTable)te, x, y, z, tick);
      }
      public void renderTileEntityTableAt(TileEntityTable te, double x, double y, double z, float tick)
      {
      GL11.glPushMatrix();
      GL11.glTranslated(x + 0.5F, y + 1.5F, z + 0.5F);
      this.bindTexture(textureLocation);
      GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
      this.model.render(0.0625F);
      GL11.glPopMatrix();
      
      }
      
      }
      
      

      ClientProxy:

      
      public class ClientProxy extends CommonProxy
      {
      public static int renderInventoryTable;
      
      public void registerRender()
      {
      renderInventoryTable = RenderingRegistry.getNextAvailableRenderId();
      RenderingRegistry.registerBlockHandler(new TableInventoryRenderer());
      }
      
      public void registerTileEntityRender()
      {
      ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTable.class, new TileEntityTableSpecialRender());
      TableInventoryRenderer.blockByTESR.put(new TESRIndex(Machines.BlockTable, 0), new TileEntityTableSpecialRender());
      }
      }
      
      

      CommonProxy:

      
      public class CommonProxy
      {
      public static int renderInventoryTable;
      private static final Map <string, nbttagcompound="">extendedEntityData = new HashMap<string, nbttagcompound="">();
      
      public static void storeEntityData(String name, NBTTagCompound compound)
      {
      extendedEntityData.put(name, compound);
      }
      
      public static NBTTagCompound getEntityData(String name)
      {
      return extendedEntityData.remove(name);
      }
      
      public void registerRender()
      {
      System.out.println("[Energie Mod] Methode executé côter SERVEUR");
      }
      
      public void registerTileEntityRender() {
      ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTable.class, new TileEntityTableSpecialRender());
      TableInventoryRenderer.blockByTESR.put(new TESRIndex(Machines.BlockTable, 0), new TileEntityTableSpecialRender());
      }
      }
      
      

      Voila, au pire si tu trouve pas je ferai une vidéo pour te montrer</string,></string,></tesrindex,></tesrindex,>

      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

        Dans le CommonProxy, la fonction registerTileEntityRender devrait être vide sinon ça va crash.

        Mais pour le problème d’invisibilité, je vois pas d’où ça vient 😕

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

          Je ne peux faire de vidéos pour le moment, y a t-il un moyen de te montrer?

          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

            M’envoyer le mod ?

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

              http://www.mediafire.com/download/5vd4i13ruh2tz2i/mods_1.7.2.rar

              J’ai que ca a mettre: pour les map (pour la map, créer s-en une, la table est dans la tabBlock tout en bas nommée tile.blocktable.name (j’ai pas mis de nom pour le moment)

              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

                Pourquoi tu as envoyé tout forge o_O
                Le dossier src suffit largement.

                Bon visiblement le problème vient du tile entity, comme tu n’utilises pas la direction, il doit être vide :

                package fr.yohannlog.machinesplus;
                
                import net.minecraft.tileentity.TileEntity;
                
                public class TileEntityTable extends TileEntity
                {
                
                }
                
                1 réponse Dernière réponse Répondre Citer 0
                • Y Hors-ligne
                  yohannlog
                  dernière édition par

                  Oui merci, ca marche enfin, et dsl de tout t’avoir envoyé tout forge

                  Juste avant de clore le sujet est-ce-que je peux faire en sorte que quand tu casse la table ca ne fasse pas des particules noir et rose?

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

                    Oui tu peut, il te suffit e faire un

                    .setTextureName("modid:tatexture")
                    
                    1 réponse Dernière réponse Répondre Citer 0
                    • Y Hors-ligne
                      yohannlog
                      dernière édition par

                      Je le met ou?

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

                        BlockTable = new BlockTable(15000, Material.wood).setBlockName("BlockTable").setCreativeTab(CreativeTabs.tabBlock)*.setTextureName("modid:tatexture")*;
                        
                        1 réponse Dernière réponse Répondre Citer 0
                        • Y Hors-ligne
                          yohannlog
                          dernière édition par

                          Ca ne marche pas car .setTextureName n’est pas de la 1.7 c’est .setBlockTextureName mais apres je sais pas si ca va marcher


                          Ca marche c’est bon , je cloture le sujet

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

                            Je pence que c’est pareil en 1.7

                            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

                              Il faut aussi ajouter une texture du même nom avec la taille 16x16.
                              Ou alors tu peux utiliser

                              public IIcon getIcon(int side, int metadata)
                              {
                              return Blocks.wood.getIcon(0, 0);
                              }
                              

                              Pour utiliser la texture du bois par exemple.

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

                              MINECRAFT FORGE FRANCE © 2024

                              Powered by NodeBB