• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Résolu Problème avec mon TileEntity et Container

    1.8.x
    1.8
    5
    20
    3050
    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.
    • w67clement
      w67clement dernière édition par

      Bonjour, j’ai un gros problème, il y a quelques temps j’ai créé un bloc de caisse, ce bloc étant un container, j’ai suivit ce tutoriel: http://www.minecraftforgefrance.fr/showthread.php?tid=2082

      Cependant, quand mon mods écrit le NBT, cela génère cette erreur:

      [10:31:36] [Server thread/ERROR] [FML]: A TileEntity type fr.w67clement.mods67.common.tileentity.TileEntityCase has throw an exception trying to write state. It will not persist. Report this to the mod author
      java.lang.RuntimeException: class fr.w67clement.mods67.common.tileentity.TileEntityCase is missing a mapping! This is a bug!
      at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:94) ~[TileEntity.class:?]
      at fr.w67clement.mods67.common.tileentity.TileEntityCase.writeToNBT(TileEntityCase.java:41) ~[TileEntityCase.class:?]
      at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:410) [AnvilChunkLoader.class:?]
      at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:193) [AnvilChunkLoader.class:?]
      at net.minecraft.world.gen.ChunkProviderServer.saveChunkData(ChunkProviderServer.java:266) [ChunkProviderServer.class:?]
      at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:332) [ChunkProviderServer.class:?]
      at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:976) [WorldServer.class:?]
      at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:419) [MinecraftServer.class:?]
      at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:147) [IntegratedServer.class:?]
      at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?]
      at java.lang.Thread.run(Unknown Source) [?:1.8.0_51]
      

      Et le code que j’ai adapté pour la 1.8:
      BlockCase:

      package fr.w67clement.mods67.common.blocks.storage;
      
      import net.minecraft.block.Block;
      import net.minecraft.block.material.Material;
      import net.minecraft.block.state.IBlockState;
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.entity.item.EntityItem;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.inventory.IInventory;
      import net.minecraft.item.ItemStack;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.tileentity.TileEntity;
      import net.minecraft.util.BlockPos;
      import net.minecraft.util.EnumFacing;
      import net.minecraft.world.World;
      import fr.w67clement.mods67.Mods67;
      import fr.w67clement.mods67.common.Mods67Blocks;
      import fr.w67clement.mods67.common.tileentity.TileEntityCase;
      
      public class BlockCase extends Block {
      private String name;
      
      public BlockCase(Material materialIn) {
      super(materialIn);
      this.name = Mods67Blocks.CASE_BLOCK.getUnlocalizedName();
      this.setCreativeTab(Mods67.getTab());
      this.setStepSound(this.soundTypeWood);
      this.setUnlocalizedName(this.name);
      this.setHardness(2.5F);
      }
      
      public String getName() {
      return this.name;
      }
      
      @Override
      public TileEntity createTileEntity(World world, IBlockState state) {
      if (hasTileEntity(state)) {
      return new TileEntityCase();
      }
      return null;
      }
      
      @Override
      public boolean hasTileEntity(IBlockState state) {
      if (state.getBlock() == this) {
      return true;
      }
      return false;
      }
      
      @Override
      public boolean onBlockActivated(World world, BlockPos pos,
      IBlockState state, EntityPlayer player, EnumFacing side,
      float hitX, float hitY, float hitZ) {
      if (world.isRemote) {
      return true;
      } else {
      player.openGui(Mods67.instance, 0, world, pos.getX(), pos.getY(),
      pos.getZ());
      return true;
      }
      }
      
      @Override
      public void breakBlock(World world, BlockPos pos, IBlockState state) {
      TileEntity tileentity = world.getTileEntity(pos);
      
      if (tileentity instanceof IInventory) {
      IInventory inv = (IInventory) tileentity;
      for (int i1 = 0; i1 < inv.getSizeInventory(); ++i1) {
      ItemStack itemstack = inv.getStackInSlot(i1);
      
      if (itemstack != null) {
      float f = world.rand.nextFloat() * 0.8F + 0.1F;
      float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
      EntityItem entityitem;
      
      for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world
      .spawnEntityInWorld(entityitem)) {
      int j1 = world.rand.nextInt(21) + 10;
      
      if (j1 > itemstack.stackSize) {
      j1 = itemstack.stackSize;
      }
      
      itemstack.stackSize -= j1;
      entityitem = new EntityItem(world,
      (double) ((float) pos.getX() + f),
      (double) ((float) pos.getY() + f1),
      (double) ((float) pos.getZ() + f2),
      new ItemStack(itemstack.getItem(), j1,
      itemstack.getItemDamage()));
      float f3 = 0.05F;
      entityitem.motionX = (double) ((float) world.rand
      .nextGaussian() * f3);
      entityitem.motionY = (double) ((float) world.rand
      .nextGaussian() * f3 + 0.2F);
      entityitem.motionZ = (double) ((float) world.rand
      .nextGaussian() * f3);
      
      if (itemstack.hasTagCompound()) {
      entityitem.getEntityItem().setTagCompound(
      (NBTTagCompound) itemstack.getTagCompound()
      .copy());
      }
      }
      }
      }
      }
      super.breakBlock(world, pos, state);
      }
      
      public void onBlockPlacedBy(World world, BlockPos pos, EntityLivingBase living, ItemStack stack)
      {
      TileEntity tile = world.getTileEntity(pos);
      if(tile instanceof TileEntityCase)
      {
      if(stack.hasDisplayName())
      {
      ((TileEntityCase)tile).setCustomName(stack.getDisplayName());
      }
      }
      }
      }
      
      

      TileEntityCase:

      package fr.w67clement.mods67.common.tileentity;
      
      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.TileEntity;
      import net.minecraft.util.ChatComponentText;
      import net.minecraft.util.IChatComponent;
      import net.minecraftforge.common.util.Constants;
      
      public class TileEntityCase extends TileEntity implements IInventory {
      
      private ItemStack[] contents = new ItemStack[27];
      private String customName;
      
      @Override
      public void readFromNBT(NBTTagCompound compound) {
      super.readFromNBT(compound);
      if (compound.hasKey("CustomName", Constants.NBT.TAG_STRING)) {
      this.customName = compound.getString("CustomName");
      }
      
      NBTTagList nbttaglist = compound.getTagList("Items",
      Constants.NBT.TAG_COMPOUND);
      this.contents = new ItemStack[this.getSizeInventory()];
      for (int i = 0; i < nbttaglist.tagCount(); ++i) {
      NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
      int j = nbttagcompound1.getByte("Slot") & 255;
      
      if (j >= 0 && j < this.contents.length) {
      this.contents[j] = ItemStack
      .loadItemStackFromNBT(nbttagcompound1);
      }
      }
      }
      
      @Override
      public void writeToNBT(NBTTagCompound compound) {
      super.writeToNBT(compound);
      if(this.hasCustomName())
      {
      compound.setString("CustomName", this.customName);
      }
      
      NBTTagList nbttaglist = new NBTTagList();
      for(int i = 0; i < this.contents.length; ++i)
      {
      if(this.contents[ i] != null)
      {
      NBTTagCompound nbttagcompound1 = new NBTTagCompound();
      nbttagcompound1.setByte("Slot", (byte)i);
      this.contents[ i].writeToNBT(nbttagcompound1);
      nbttaglist.appendTag(nbttagcompound1);
      }
      }
      compound.setTag("Items", nbttaglist);
      }
      
      @Override
      public String getName() {
      return this.hasCustomName() ? this.customName : "tile.case_block";
      }
      
      @Override
      public boolean hasCustomName() {
      return this.customName != null;
      }
      
      @Override
      public IChatComponent getDisplayName() {
      return new ChatComponentText(this.getName());
      }
      
      public void setCustomName(String customName) {
      this.customName = customName;
      }
      
      @Override
      public int getSizeInventory() {
      return this.contents.length;
      }
      
      @Override
      public ItemStack getStackInSlot(int index) {
      return this.contents[index];
      }
      
      @Override
      public ItemStack decrStackSize(int index, int count) {
      if (this.contents[index] != null) {
      ItemStack itemstack;
      
      if (this.contents[index].stackSize <= count) {
      itemstack = this.contents[index];
      this.contents[index] = null;
      this.markDirty();
      return itemstack;
      } else // sinon
      {
      itemstack = this.contents[index].splitStack(count);
      
      if (this.contents[index].stackSize == 0) {
      this.contents[index] = null;
      }
      this.markDirty();
      return itemstack;
      }
      } else {
      return null;
      }
      }
      
      @Override
      public ItemStack getStackInSlotOnClosing(int index) {
      if (this.contents[index] != null) {
      ItemStack itemstack = this.contents[index];
      this.contents[index] = null;
      return itemstack;
      } else {
      return null;
      }
      }
      
      @Override
      public void setInventorySlotContents(int index, ItemStack stack) {
      this.contents[index] = stack;
      
      if (stack != null && stack.stackSize > this.getInventoryStackLimit()) {
      stack.stackSize = this.getInventoryStackLimit();
      }
      
      this.markDirty();
      }
      
      @Override
      public int getInventoryStackLimit() {
      return 64;
      }
      
      @Override
      public boolean isUseableByPlayer(EntityPlayer player) {
      return this.worldObj.getTileEntity(this.pos) != this ? false : player
      .getDistanceSq((double) this.pos.getX() + 0.5D,
      (double) this.pos.getY() + 0.5D,
      (double) this.pos.getZ() + 0.5D) <= 64.0D;
      }
      
      @Override
      public void openInventory(EntityPlayer player) {
      }
      
      @Override
      public void closeInventory(EntityPlayer player) {
      
      }
      
      @Override
      public boolean isItemValidForSlot(int index, ItemStack stack) {
      return true;
      }
      
      @Override
      public int getField(int id) {
      return 0;
      }
      
      @Override
      public void setField(int id, int value) {
      }
      
      @Override
      public int getFieldCount() {
      return 0;
      }
      
      @Override
      public void clear() {
      for (ItemStack items : this.contents) {
      if (items != null) {
      items = null;
      }
      }
      }
      
      }
      
      

      CaseContainer:

      package fr.w67clement.mods67.common.container;
      
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.entity.player.InventoryPlayer;
      import net.minecraft.inventory.Container;
      import net.minecraft.inventory.Slot;
      import net.minecraft.item.ItemStack;
      import fr.w67clement.mods67.common.tileentity.TileEntityCase;
      
      public class CaseContainer extends Container {
      
      private TileEntityCase tileCase;
      
      public CaseContainer(TileEntityCase tile, InventoryPlayer inventory) {
      this.tileCase = tile;
      
      tileCase.openInventory(inventory.player);
      for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 9; ++j) {
      this.addSlotToContainer(new Slot(tile, j + i * 9, 8 + j * 18,
      18 + i * 18));
      }
      }
      this.bindPlayerInventory(inventory);
      }
      
      @Override
      public boolean canInteractWith(EntityPlayer playerIn) {
      return this.tileCase.isUseableByPlayer(playerIn);
      }
      
      @Override
      public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
      ItemStack itemstack = null;
      Slot slot = (Slot) this.inventorySlots.get(slotIndex);
      
      if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();
      
      if (slotIndex < this.tileCase.getSizeInventory()) {
      if (!this.mergeItemStack(itemstack1,
      this.tileCase.getSizeInventory(),
      this.inventorySlots.size(), true)) {
      return null;
      }
      } else if (!this.mergeItemStack(itemstack1, 0,
      this.tileCase.getSizeInventory(), false)) {
      return null;
      }
      
      if (itemstack1.stackSize == 0) {
      slot.putStack((ItemStack) null);
      } else {
      slot.onSlotChanged();
      }
      }
      return itemstack;
      }
      
      @Override
      public void onContainerClosed(EntityPlayer player)
      {
      super.onContainerClosed(player);
      this.tileCase.closeInventory(player);
      }
      
      private void bindPlayerInventory(InventoryPlayer inventory) {
      int i;
      for (i = 0; i < 3; ++i) {
      for (int j = 0; j < 9; ++j) {
      this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9,
      8 + j * 18, 86 + i * 18));
      }
      }
      
      for (i = 0; i < 9; ++i) {
      this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 144));
      }
      }
      }
      

      Mon GUI Handler:

      package fr.w67clement.mods67.common.gui;
      
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.tileentity.TileEntity;
      import net.minecraft.util.BlockPos;
      import net.minecraft.world.World;
      import net.minecraftforge.fml.common.network.IGuiHandler;
      import fr.w67clement.mods67.client.gui.CaseGui;
      import fr.w67clement.mods67.common.container.CaseContainer;
      import fr.w67clement.mods67.common.tileentity.TileEntityCase;
      
      public class Mods67GuiHandler implements IGuiHandler {
      
      @Override
      public Object getServerGuiElement(int ID, EntityPlayer player, World world,
      int x, int y, int z) {
      TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
      if (tile instanceof TileEntityCase) {
      return new CaseContainer((TileEntityCase) tile, player.inventory);
      }
      return null;
      }
      
      @Override
      public Object getClientGuiElement(int ID, EntityPlayer player, World world,
      int x, int y, int z) {
      TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
      if (tile instanceof TileEntityCase) {
      return new CaseGui((TileEntityCase) tile,
      player.inventory);
      }
      return null;
      }
      
      }
      
      

      Et mon GUI:

      package fr.w67clement.mods67.client.gui;
      
      import net.minecraft.client.gui.inventory.GuiContainer;
      import net.minecraft.client.resources.I18n;
      import net.minecraft.entity.player.InventoryPlayer;
      import net.minecraft.inventory.IInventory;
      import net.minecraft.util.ResourceLocation;
      
      import org.lwjgl.opengl.GL11;
      
      import fr.w67clement.mods67.common.container.CaseContainer;
      import fr.w67clement.mods67.common.tileentity.TileEntityCase;
      
      public class CaseGui extends GuiContainer {
      
      private static final ResourceLocation textures = new ResourceLocation(
      "minecraft:textures/gui/container/generic_54.png");
      private TileEntityCase tileentity;
      private IInventory playerInv;
      private int inventoryRows;
      
      public CaseGui(TileEntityCase tile, InventoryPlayer inventory) {
      super(new CaseContainer(tile, inventory));
      this.tileentity = tile;
      this.playerInv = inventory;
      this.allowUserInput = false;
      this.ySize = 170;
      this.inventoryRows = tile.getSizeInventory();
      }
      
      protected void drawGuiContainerForegroundLayer(int x, int y) {
      String tileName = this.tileentity.hasCustomName() ? this.tileentity
      .getName() : I18n.format(this.tileentity
      .getName());
      this.fontRendererObj
      .drawString(tileName, (this.xSize - this.fontRendererObj
      .getStringWidth(tileName)) / 2, 6, 0);
      String invName = this.playerInv.hasCustomName() ? this.playerInv
      .getName() : I18n.format(this.playerInv
      .getName());
      this.fontRendererObj
      .drawString(invName, (this.xSize - this.fontRendererObj
      .getStringWidth(invName)) / 2, this.ySize - 96, 0);
      }
      
      @Override
      protected void drawGuiContainerBackgroundLayer(float partialTicks,
      int mouseX, int mouseY) {
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      this.mc.getTextureManager().bindTexture(textures);
      int k = (this.width - this.xSize) / 2;
      int l = (this.height - this.ySize) / 2;
      this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.inventoryRows * 18 + 17);
      this.drawTexturedModalRect(k, l + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96);
      }
      }
      
      

      Voilà, en espérant que quelqu’un a la solution à mon problème 😄

      1 réponse Dernière réponse Répondre Citer 0
      • Eryah
        Eryah dernière édition par

        Salut.
        Que ce passe-t-il réellement ?
        Arrive-tu a ouvrir ton container ?
        Crash-tu lors de l’ouverture ?
        Ou rien ne s’ouvre, et tu a ce texte dans les logs ?

        (Sinon, je te conseille d’utiliser le terme Crate pour ta caisse, car case est peu utilisé pour le mot Caisse)

        Membre fantôme
        Je développe maintenant un jeu sur UnrealEngine4


        Contact :…

        1 réponse Dernière réponse Répondre Citer 0
        • w67clement
          w67clement dernière édition par

          @‘Eryah’:

          Salut.
          Que ce passe-t-il réellement ?
          Arrive-tu a ouvrir ton container ?
          Crash-tu lors de l’ouverture ?
          Ou rien ne s’ouvre, et tu a ce texte dans les logs ?

          (Sinon, je te conseille d’utiliser le terme Crate pour ta casse, car case est peu utilisé pour le mot Caisse)

          Je peux l’ouvrir, je peux mettre des items dedans mais dès que le jeux se mets sur pause (et sauvegarde le monde), cette erreur apparaît

          1 réponse Dernière réponse Répondre Citer 0
          • Eryah
            Eryah dernière édition par

            Donc c’est juste un petit bug a régler ?
            Ca ne pose pas grand problèmes, car en client normal, on n’a pas ces logs ( Sauf si tu a la console ouverte )
            Ou j’ai mal compris l’erreur, et quand tu sauvgarde, tu crash ?
            Je vais quand même essayer de régler cela

            EDIT : Essayer d’enlever le super dans le wirte to NBT ( Je ne garanti pas les résultats, mais ça pourrait être cela )

            Membre fantôme
            Je développe maintenant un jeu sur UnrealEngine4


            Contact :…

            1 réponse Dernière réponse Répondre Citer 0
            • w67clement
              w67clement dernière édition par

              Il n’y a plus l’erreur, mais les items présents dans la caisse ne sont pas sauvegardés 😞

              Edit: Si quelqu’un connaît un tutoriel sur les containers en 1.8? Si oui peut-on me le passer?

              1 réponse Dernière réponse Répondre Citer 0
              • Eryah
                Eryah dernière édition par

                Ok, retournement de veste, remet ton super
                l’erreur vient surement du fait que ton tile entity doit etre extends TileEntityLockable et implements IUpdatePlayerListBox, IInventory

                Je te conseille de regarder, voir de copier-coller les classes de base de minecraft quand tu veut faire quelque chose de semblable a une chose déja existante

                Membre fantôme
                Je développe maintenant un jeu sur UnrealEngine4


                Contact :…

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

                  Tous ton code est bon.
                  Franchement lisez bien les pré-requis. Ça sert à rien de vouloir faire un container si tu ne sais même pas faire un tile entity correctement. En plus c’est écrit noir sur blanc :
                  java.lang.RuntimeException: class fr.w67clement.mods67.common.tileentity.TileEntityCase is missing a mapping! This is a bug!
                  Tu n’as pas enregistré ton tile entity.
                  (remet aussi le super.writeToNBT(compound); il ne faut surtout pas le retirer)

                  1 réponse Dernière réponse Répondre Citer 0
                  • w67clement
                    w67clement dernière édition par

                    Merci robin, effectivement c’était bien cela le problème (En fait je n’avais pas vu la partie qui disait qu’il fallait enregistrer le TileEntity, désolée :/).

                    Par contre j’ai un autre problème:

                    Serait-il possible de me guider pour corriger ce bug d’affichage?

                    Le code est le même à part ça:

                    for (int i = 0; i < 3; ++i) {
                    for (int j = 0; j < 9; ++j) {
                    this.addSlotToContainer(new Slot(tile, j + i * 9, 8 + j * 18,
                    18 + i * 18));
                    }
                    }
                    

                    Dont le 3 a été remplacé par 4.
                    Et il y a aussi ça de modifier:

                    private static final ResourceLocation textures = new ResourceLocation(
                    "minecraft:textures/gui/container/generic_54.png");
                    

                    Qui est maintenant ça:

                    private static final ResourceLocation textures = new ResourceLocation(
                    "mods67:textures/gui/container/crate_gui.png");
                    

                    Je vous remercie d’avance pour votre aide ^^

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

                      Le placement des slots et l’affichage du texte se fait en fonction de ta texture : il faut regarder le nombre de pixels sur la base 256 (donc si ta texture fait 512x512, tu dois diviser les distances par 2).

                      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
                      • robin4002
                        robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par

                        Si tu veux faire un container de 49 au lieu de 39 il faut adapter les coordonnées des slot et des fonctions drawScreen

                        1 réponse Dernière réponse Répondre Citer 0
                        • w67clement
                          w67clement dernière édition par

                          Merci c’était bien cela mais il me reste un tout dernier bug:

                          Quelqu’un a une idée de comment régler ce bug?

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

                            Tu n’as pas changé la taille du GUI : il faut mettre la largeur et la hauteur de ton image sur la base 256.

                            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
                            • w67clement
                              w67clement dernière édition par

                              @‘SCAREX’:

                              Tu n’as pas changé la taille du GUI : il faut mettre la largeur et la hauteur de ton image sur la base 256.

                              Comment je modifie cette taille?

                              J’ai essayé de changer ySize mais cela ne règle pas le bug.

                              1 réponse Dernière réponse Répondre Citer 0
                              • DiabolicaTrix
                                DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par

                                Il faut que tu le change par rapport à la taille exacte de ton gui

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

                                  Code de ton gui + image png de ton gui.

                                  1 réponse Dernière réponse Répondre Citer 0
                                  • w67clement
                                    w67clement dernière édition par

                                    Code de mon gui:

                                    package fr.w67clement.mods67.client.gui;
                                    
                                    import net.minecraft.client.gui.inventory.GuiContainer;
                                    import net.minecraft.client.resources.I18n;
                                    import net.minecraft.entity.player.InventoryPlayer;
                                    import net.minecraft.inventory.IInventory;
                                    import net.minecraft.util.ResourceLocation;
                                    
                                    import org.lwjgl.opengl.GL11;
                                    
                                    import fr.w67clement.mods67.common.container.CaseContainer;
                                    import fr.w67clement.mods67.common.tileentity.TileEntityCase;
                                    
                                    public class GuiCrate extends GuiContainer {
                                    
                                    private static final ResourceLocation textures = new ResourceLocation(
                                    "mods67:textures/gui/container/crate_gui.png");
                                    private TileEntityCase tileentity;
                                    private IInventory playerInv;
                                    private int inventoryRows;
                                    
                                    public CaseGui(TileEntityCase tile, InventoryPlayer inventory) {
                                    super(new CaseContainer(tile, inventory));
                                    this.tileentity = tile;
                                    this.playerInv = inventory;
                                    this.allowUserInput = false;
                                    this.ySize = 256;
                                    this.inventoryRows = tile.getSizeInventory();
                                    }
                                    
                                    protected void drawGuiContainerForegroundLayer(int x, int y) {
                                    String tileName = this.tileentity.hasCustomName() ? this.tileentity
                                    .getName() : I18n.format(this.tileentity
                                    .getName());
                                    this.fontRendererObj
                                    .drawString(tileName, 8, 6, 4210752);
                                    String invName = this.playerInv.hasCustomName() ? this.playerInv
                                    .getName() : I18n.format(this.playerInv
                                    .getName());
                                    this.fontRendererObj
                                    .drawString(invName, 8, this.ySize - 78, 4210752);
                                    }
                                    
                                    @Override
                                    protected void drawGuiContainerBackgroundLayer(float partialTicks,
                                    int mouseX, int mouseY) {
                                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                                    this.mc.getTextureManager().bindTexture(textures);
                                    int k = (this.width - this.xSize) / 2;
                                    int l = (this.height - this.ySize) / 2;
                                    this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.inventoryRows * 18 + 17);
                                    this.drawTexturedModalRect(k, l + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96);
                                    }
                                    }
                                    
                                    

                                    Image de mon gui:

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

                                      this.ySize = 256;

                                      J’ai dit mettre la taille de ton GUI sur une base 256 pas la taille de la texture. Dans ton cas, la taille de ton image est de 176*186.
                                      Mets çà dans ton constructeur :
                                      this.xSize = 176;
                                      this.ySize = 186;

                                      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
                                      • w67clement
                                        w67clement dernière édition par

                                        J’ai mis ce que tu m’as dit de mettre, mais le bug persiste:

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

                                          Normal, tu as 2 draw, le chest en utilise 2 pour utiliser plusieurs lignes. Mais si tu n’en as pas besoin, tu peux enlever le 2ème et mettre this.ySize en dernier paramètre.

                                          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
                                          • w67clement
                                            w67clement dernière édition par

                                            Effectivement, c’était ça, merci SCAREX ^^

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

                                            MINECRAFT FORGE FRANCE © 2018

                                            Powered by NodeBB