MFF

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

    Un bug avec un coffre

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    7 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.
    • P Hors-ligne
      PlayFlop_
      dernière édition par

      Bonjour,

      Je viens de créer un coffre.
      Tout ce qu’il y a de plus normal
      Tout fonctionne bien sauf une chose.
      Premièrement, la texture du coffre est mise, mais quand j’ai le bloc du coffre dans la main, c’est invisible…
      Ensuite, quand je met des items dans le coffre, si je déco du monde et que je me reconnecte dedans, les items disparaissent…

      Merci de votre aide!

      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

        Salut,
        Pour le rendu en main, tu as surement loupé une des étapes du tutoriel de rendu TESR : https://www.minecraftforgefrance.fr/showthread.php?tid=1509#classe4

        Pour les items, envoies le code de ton tile entity.

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

          @‘robin4002’:

          Salut,
          Pour le rendu en main, tu as surement loupé une des étapes du tutoriel de rendu TESR : https://www.minecraftforgefrance.fr/showthread.php?tid=1509#classe4

          Pour les items, envoies le code de ton tile entity.

          Le render est Fixé
          Voila mon TileEntity

          package fr.playflop.legitium.proxy;
          
          import cpw.mods.fml.common.FMLLog;
          import cpw.mods.fml.relauncher.Side;
          import cpw.mods.fml.relauncher.SideOnly;
          
          import java.util.Calendar;
          
          import net.minecraft.client.model.ModelChest;
          import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
          import net.minecraft.tileentity.TileEntity;
          import net.minecraft.util.ResourceLocation;
          
          import org.lwjgl.opengl.GL11;
          
          import fr.playflop.legitium.common.block.BlockFluoriteChest;
          import fr.playflop.legitium.common.block.TileEntityFluoriteChest;
          
          @SideOnly(Side.CLIENT)
          public class TileEntityFluoriteChestSpecialRenderer
            extends TileEntitySpecialRenderer
          {
            public static final ResourceLocation a = new ResourceLocation("eraknight", "textures/models/EraChest.png");
            public static ModelChest b = new ModelChest();
            private boolean c;
          
            public TileEntityFluoriteChestSpecialRenderer()
            {
              Calendar localCalendar = Calendar.getInstance();
              if ((localCalendar.get(2) + 1 == 12) && (localCalendar.get(5) >= 24) && (localCalendar.get(5) <= 26)) {
                this.c = true;
              }
            }
          
            public void renderTileEntityAt(TileEntityFluoriteChest paramTileEntityFluoriteChest, double paramDouble1, double paramDouble2, double paramDouble3, float paramFloat)
            {
              int i;
              Object localObject;
              if (!paramTileEntityFluoriteChest.hasWorldObj())
              {
                i = 0;
              }
              else
              {
                localObject = paramTileEntityFluoriteChest.getBlockType();
                i = paramTileEntityFluoriteChest.getBlockMetadata();
                if (((localObject instanceof BlockFluoriteChest)) && (i == 0))
                {
                  try
                  {
                    ((BlockFluoriteChest)localObject).func_149951_m(paramTileEntityFluoriteChest.getWorldObj(), paramTileEntityFluoriteChest.xCoord, paramTileEntityFluoriteChest.yCoord, paramTileEntityFluoriteChest.zCoord);
                  }
                  catch (ClassCastException localClassCastException)
                  {
                    FMLLog.severe("Attempted to render a chest at %d,  %d, %d that was not a chest", new Object[] { Integer.valueOf(paramTileEntityFluoriteChest.xCoord), Integer.valueOf(paramTileEntityFluoriteChest.yCoord), Integer.valueOf(paramTileEntityFluoriteChest.zCoord) });
                  }
                  i = paramTileEntityFluoriteChest.getBlockMetadata();
                }
              }
              if ((paramTileEntityFluoriteChest.a == null) && (paramTileEntityFluoriteChest.c == null))
              {
                if ((paramTileEntityFluoriteChest.b == null) && (paramTileEntityFluoriteChest.d == null))
                {
                  localObject = b;
                  bindTexture(a);
                }
                else
                {
                  localObject = b;
                  bindTexture(a);
                }
                GL11.glPushMatrix();
                GL11.glEnable(32826);
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                GL11.glTranslatef((float)paramDouble1, (float)paramDouble2 + 1.0F, (float)paramDouble3 + 1.0F);
                GL11.glScalef(1.0F, -1.0F, -1.0F);
                GL11.glTranslatef(0.5F, 0.5F, 0.5F);
                int j = 0;
                if (i == 2) {
                  j = 180;
                }
                if (i == 3) {
                  j = 0;
                }
                if (i == 4) {
                  j = 90;
                }
                if (i == 5) {
                  j = -90;
                }
                if ((i == 2) && (paramTileEntityFluoriteChest.b != null)) {
                  GL11.glTranslatef(1.0F, 0.0F, 0.0F);
                }
                if ((i == 5) && (paramTileEntityFluoriteChest.d != null)) {
                  GL11.glTranslatef(0.0F, 0.0F, -1.0F);
                }
                GL11.glRotatef(j, 0.0F, 1.0F, 0.0F);
                GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
                float f1 = paramTileEntityFluoriteChest.prevLidAngle + (paramTileEntityFluoriteChest.lidAngle - paramTileEntityFluoriteChest.prevLidAngle) * paramFloat;
                float f2;
                if (paramTileEntityFluoriteChest.a != null)
                {
                  f2 = paramTileEntityFluoriteChest.a.prevLidAngle + (paramTileEntityFluoriteChest.a.lidAngle - paramTileEntityFluoriteChest.a.prevLidAngle) * paramFloat;
                  if (f2 > f1) {
                    f1 = f2;
                  }
                }
                if (paramTileEntityFluoriteChest.c != null)
                {
                  f2 = paramTileEntityFluoriteChest.c.prevLidAngle + (paramTileEntityFluoriteChest.c.lidAngle - paramTileEntityFluoriteChest.c.prevLidAngle) * paramFloat;
                  if (f2 > f1) {
                    f1 = f2;
                  }
                }
                f1 = 1.0F - f1;
                f1 = 1.0F - f1 * f1 * f1;
                ((ModelChest)localObject).chestLid.rotateAngleX = (-(f1 * 3.1415927F / 2.0F));
                ((ModelChest)localObject).renderAll();
                GL11.glDisable(32826);
                GL11.glPopMatrix();
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
              }
            }
          
            public void renderTileEntityAt(TileEntity paramTileEntity, double paramDouble1, double paramDouble2, double paramDouble3, float paramFloat)
            {
              renderTileEntityAt((TileEntityFluoriteChest)paramTileEntity, paramDouble1, paramDouble2, paramDouble3, paramFloat);
            }
          }
          
          
          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 as envoyé le tile entity special renderer au lieu du tile entity.

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

              package fr.playflop.legitium.common.block;
              
              import net.minecraft.entity.player.EntityPlayer;
              import net.minecraft.inventory.IInventory;
              import net.minecraft.item.ItemStack;
              import net.minecraft.nbt.NBTTagCompound;
              import net.minecraft.nbt.NBTTagList;
              import net.minecraft.tileentity.TileEntityChest;
              import net.minecraft.world.World;
              
              public class TileEntityFluoriteChest
                extends TileEntityChest
                implements IInventory
              {
                public TileEntityFluoriteChest a;
                public TileEntityFluoriteChest b;
                public TileEntityFluoriteChest c;
                public TileEntityFluoriteChest d;
                private ItemStack[] e = new ItemStack[54];
                private String f;
              
                public void readFromNBT(NBTTagCompound paramNBTTagCompound)
                {
                  super.readFromNBT(paramNBTTagCompound);
                  if (paramNBTTagCompound.hasKey("eraknight", 8)) {
                    this.f = paramNBTTagCompound.getString("eraknight");
                  }
                  NBTTagList localNBTTagList = paramNBTTagCompound.getTagList("Items", 10);
                  this.e = new ItemStack[getSizeInventory()];
                  for (int i = 0; i < localNBTTagList.tagCount(); i++)
                  {
                    NBTTagCompound localNBTTagCompound = localNBTTagList.getCompoundTagAt(i);
                    int j = localNBTTagCompound.getByte("Slot") & 0xFF;
                    if ((j >= 0) && (j < this.e.length)) {
                      this.e[j] = ItemStack.loadItemStackFromNBT(localNBTTagCompound);
                    }
                  }
                }
              
                public void writeToNBT(NBTTagCompound paramNBTTagCompound)
                {
                  super.writeToNBT(paramNBTTagCompound);
                  if (hasCustomInventoryName()) {
                    paramNBTTagCompound.setString("eraknight", this.f);
                  }
                  NBTTagList localNBTTagList = new NBTTagList();
                  for (int i = 0; i < this.e.length; i++) {
                    if (this.e* != null)
                    {
                      NBTTagCompound localNBTTagCompound = new NBTTagCompound();
                      localNBTTagCompound.setByte("Slot", (byte)i);
                      this.e*.writeToNBT(localNBTTagCompound);
                      localNBTTagList.appendTag(localNBTTagCompound);
                    }
                  }
                  paramNBTTagCompound.setTag("Items", localNBTTagList);
                }
              
                public int getSizeInventory()
                {
                  return this.e.length;
                }
              
                public ItemStack getStackInSlot(int paramInt)
                {
                  return this.e[paramInt];
                }
              
                public ItemStack decrStackSize(int paramInt1, int paramInt2)
                {
                  if (this.e[paramInt1] != null)
                  {
                    if (this.e[paramInt1].stackSize <= paramInt2)
                    {
                      ItemStack localItemStack = this.e[paramInt1];
                      this.e[paramInt1] = null;
                      markDirty();
                      return localItemStack;
                    }
                    ItemStack localItemStack = this.e[paramInt1].splitStack(paramInt2);
                    if (this.e[paramInt1].stackSize == 0) {
                      this.e[paramInt1] = null;
                    }
                    markDirty();
                    return localItemStack;
                  }
                  return null;
                }
              
                public ItemStack getStackInSlotOnClosing(int paramInt)
                {
                  if (this.e[paramInt] != null)
                  {
                    ItemStack localItemStack = this.e[paramInt];
                    this.e[paramInt] = null;
                    return localItemStack;
                  }
                  return null;
                }
              
                public void setInventorySlotContents(int paramInt, ItemStack paramItemStack)
                {
                  this.e[paramInt] = paramItemStack;
                  if ((paramItemStack != null) && (paramItemStack.stackSize > getInventoryStackLimit())) {
                    paramItemStack.stackSize = getInventoryStackLimit();
                  }
                  markDirty();
                }
              
                public String getInventoryName()
                {
                  return hasCustomInventoryName() ? this.f : "inventory.era_chest";
                }
              
                public void setCustomName(String paramString)
                {
                  this.f = paramString;
                }
              
                public boolean hasCustomInventoryName()
                {
                  return false;
                }
              
                public int getInventoryStackLimit()
                {
                  return 64;
                }
              
                public boolean isUseableByPlayer(EntityPlayer paramEntityPlayer)
                {
                  return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this;
                }
              
                public void openInventory() {}
              
                public void closeInventory() {}
              
                public boolean isItemValidForSlot(int paramInt, ItemStack paramItemStack)
                {
                  return true;
                }
              }
              
              

              J’ai mit ça dans mon client proxy

              X = RenderingRegistry.getNextAvailableRenderId();
              ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFluoriteChest.class, new TileEntityFluoriteChestSpecialRenderer());
              

              Donc je suppose que moi

              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

                Les fonctions readFromNBT et writeToNBT me semble correcte, étrange que cela ne fonctionne pas.
                Ton tile entity est bien enregistré ?

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

                  @‘PlayFlop_’:

                  package fr.playflop.legitium.common.block;
                  
                  import net.minecraft.entity.player.EntityPlayer;
                  import net.minecraft.inventory.IInventory;
                  import net.minecraft.item.ItemStack;
                  import net.minecraft.nbt.NBTTagCompound;
                  import net.minecraft.nbt.NBTTagList;
                  import net.minecraft.tileentity.TileEntityChest;
                  import net.minecraft.world.World;
                  
                  public class TileEntityFluoriteChest
                    extends TileEntityChest
                    implements IInventory
                  {
                    public TileEntityFluoriteChest a;
                    public TileEntityFluoriteChest b;
                    public TileEntityFluoriteChest c;
                    public TileEntityFluoriteChest d;
                    private ItemStack[] e = new ItemStack[54];
                    private String f;
                    
                    public void readFromNBT(NBTTagCompound paramNBTTagCompound)
                    {
                      super.readFromNBT(paramNBTTagCompound);
                      if (paramNBTTagCompound.hasKey("eraknight", 8)) {
                        this.f = paramNBTTagCompound.getString("eraknight");
                      }
                      NBTTagList localNBTTagList = paramNBTTagCompound.getTagList("Items", 10);
                      this.e = new ItemStack[getSizeInventory()];
                      for (int i = 0; i < localNBTTagList.tagCount(); i++)
                      {
                        NBTTagCompound localNBTTagCompound = localNBTTagList.getCompoundTagAt(i);
                        int j = localNBTTagCompound.getByte("Slot") & 0xFF;
                        if ((j >= 0) && (j < this.e.length)) {
                          this.e[j] = ItemStack.loadItemStackFromNBT(localNBTTagCompound);
                        }
                      }
                    }
                    
                    public void writeToNBT(NBTTagCompound paramNBTTagCompound)
                    {
                      super.writeToNBT(paramNBTTagCompound);
                      if (hasCustomInventoryName()) {
                        paramNBTTagCompound.setString("eraknight", this.f);
                      }
                      NBTTagList localNBTTagList = new NBTTagList();
                      for (int i = 0; i < this.e.length; i++) {
                        if (this.e* != null)
                        {
                          NBTTagCompound localNBTTagCompound = new NBTTagCompound();
                          localNBTTagCompound.setByte("Slot", (byte)i);
                          this.e*.writeToNBT(localNBTTagCompound);
                          localNBTTagList.appendTag(localNBTTagCompound);
                        }
                      }
                      paramNBTTagCompound.setTag("Items", localNBTTagList);
                    }
                    
                    public int getSizeInventory()
                    {
                      return this.e.length;
                    }
                    
                    public ItemStack getStackInSlot(int paramInt)
                    {
                      return this.e[paramInt];
                    }
                    
                    public ItemStack decrStackSize(int paramInt1, int paramInt2)
                    {
                      if (this.e[paramInt1] != null)
                      {
                        if (this.e[paramInt1].stackSize <= paramInt2)
                        {
                          ItemStack localItemStack = this.e[paramInt1];
                          this.e[paramInt1] = null;
                          markDirty();
                          return localItemStack;
                        }
                        ItemStack localItemStack = this.e[paramInt1].splitStack(paramInt2);
                        if (this.e[paramInt1].stackSize == 0) {
                          this.e[paramInt1] = null;
                        }
                        markDirty();
                        return localItemStack;
                      }
                      return null;
                    }
                    
                    public ItemStack getStackInSlotOnClosing(int paramInt)
                    {
                      if (this.e[paramInt] != null)
                      {
                        ItemStack localItemStack = this.e[paramInt];
                        this.e[paramInt] = null;
                        return localItemStack;
                      }
                      return null;
                    }
                    
                    public void setInventorySlotContents(int paramInt, ItemStack paramItemStack)
                    {
                      this.e[paramInt] = paramItemStack;
                      if ((paramItemStack != null) && (paramItemStack.stackSize > getInventoryStackLimit())) {
                        paramItemStack.stackSize = getInventoryStackLimit();
                      }
                      markDirty();
                    }
                    
                    public String getInventoryName()
                    {
                      return hasCustomInventoryName() ? this.f : "inventory.era_chest";
                    }
                    
                    public void setCustomName(String paramString)
                    {
                      this.f = paramString;
                    }
                    
                    public boolean hasCustomInventoryName()
                    {
                      return false;
                    }
                    
                    public int getInventoryStackLimit()
                    {
                      return 64;
                    }
                    
                    public boolean isUseableByPlayer(EntityPlayer paramEntityPlayer)
                    {
                      return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this;
                    }
                    
                    public void openInventory() {}
                    
                    public void closeInventory() {}
                    
                    public boolean isItemValidForSlot(int paramInt, ItemStack paramItemStack)
                    {
                      return true;
                    }
                  }
                  
                  

                  J’ai mit ça dans mon client proxy

                  X = RenderingRegistry.getNextAvailableRenderId();
                  ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFluoriteChest.class, new TileEntityFluoriteChestSpecialRenderer());
                  

                  Donc je suppose que moi

                  Et le coffre est déclaré dans mon GuiHandler

                  Merci de ton aide, j’ai réglé mon soucis !!

                  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