MFF

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

    Book editer

    Planifier Épinglé Verrouillé Déplacé Sans suite
    1.6.4
    33 Messages 5 Publieurs 7.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

      public void drawScreen(int par1, int par2, float par3)
      {
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      this.mc.getTextureManager().bindTexture(bookGuiTextures);
      […]
      

      Il suffit juste de faire une condition ici.

      public void drawScreen(int par1, int par2, float par3)
      {
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      if(this.currPage == 0)
      {
      this.mc.getTextureManager().bindTexture(bookGuiTextures);
      }
      else if(this.currPage == 1)
      {
      this.mc.getTextureManager().bindTexture(new ResourceLocation("modid", "textures/gui/image1.png"));
      }
      else if(this.currPage == 1)
      {
      this.mc.getTextureManager().bindTexture(new ResourceLocation("modid", "textures/gui/image2.png"));
      }
      etc …
      
      1 réponse Dernière réponse Répondre Citer 0
      • M Hors-ligne
        mrkevin77
        dernière édition par

        dans la classe de mon livre il me propose pas de créer un nouveau gui il reprend direct celui de base

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

          esque l classe de mon item book et correct ?

          
          package pixelmonfr;
          
          import java.util.List;
          
          import net.minecraft.entity.player.EntityPlayer;
          import net.minecraft.item.Item;
          import net.minecraft.item.ItemStack;
          import net.minecraft.item.ItemWritableBook;
          import net.minecraft.nbt.NBTTagCompound;
          import net.minecraft.nbt.NBTTagString;
          import net.minecraft.util.EnumChatFormatting;
          import net.minecraft.util.StatCollector;
          import net.minecraft.world.World;
          import cpw.mods.fml.relauncher.Side;
          import cpw.mods.fml.relauncher.SideOnly;
          
          public class bd1 extends Item
          
          {
          
          public bd1(int par1)
          
          {
          
          super(par1);
          
          this.setMaxStackSize(1);
          
          }
          
          public static boolean validBookTagContents(NBTTagCompound par0NBTTagCompound)
          
          {
          
          if (!ItemWritableBook.validBookTagPages(par0NBTTagCompound))
          
          {
          
          return false;
          
          }
          
          else if (!par0NBTTagCompound.hasKey("title"))
          
          {
          
          return false;
          
          }
          
          else
          
          {
          
          String s = par0NBTTagCompound.getString("title");
          
          return s != null && s.length() <= 16 ? par0NBTTagCompound.hasKey("author") : false;
          
          }
          
          }
          
          public String getItemDisplayName(ItemStack par1ItemStack)
          
          {
          
          if (par1ItemStack.hasTagCompound())
          
          {
          
          NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound();
          
          NBTTagString nbttagstring = (NBTTagString)nbttagcompound.getTag("title");
          
          if (nbttagstring != null)
          
          {
          
          return nbttagstring.toString();
          
          }
          
          }
          
          return super.getItemDisplayName(par1ItemStack);
          
          }
          
          @SideOnly(Side.CLIENT)
          
          /**
          
          * allows items to add custom lines of information to the mouseover description
          
          */
          
          public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
          
          {
          
          if (par1ItemStack.hasTagCompound())
          
          {
          
          NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound();
          
          NBTTagString nbttagstring = (NBTTagString)nbttagcompound.getTag("author");
          
          if (nbttagstring != null)
          
          {
          
          par3List.add(EnumChatFormatting.GRAY + String.format(StatCollector.translateToLocalFormatted("book.byAuthor", new Object[] {nbttagstring.data}), new Object[0]));
          
          }
          
          }
          
          }
          
          /**
          
          * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
          
          75\. */
          
          public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
          
          {
          
          par3EntityPlayer.displayGUIBook(par1ItemStack);
          
          return par1ItemStack;
          
          }
          
          /**
          
          * If this function returns true (or the item is damageable), the ItemStack's NBT tag will be sent to the client.
          
          */
          
          public boolean getShareTag()
          
          {
          
          return true;
          
          }
          
          @SideOnly(Side.CLIENT)
          
          public boolean hasEffect(ItemStack par1ItemStack)
          
          {
          
          return true;
          
          }
          
          }
          
          
          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

            public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
            {
            par3EntityPlayer.displayGUIBook(par1ItemStack);
            return par1ItemStack;
            }
            

            Il faut changer ce code pour ouvrir ton gui custom. Avec forge il faut un gui handler et utiliser la fonction player.openGui. Tu peux aller voir le tutoriel pour faire un coffre, j’en parle dedans.

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

              je laisse tomber je galere trop avec se fioutu book on verra sa plus tard

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

                qulqu’un serait il en mesure de me faire la base du code ou un tuto car je galere telement avec se bouquin

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

                  bon je croit avoir enfin reussi a faire mon gui custom

                  
                  package pixelmonfr;
                  
                  import java.io.ByteArrayOutputStream;
                  import java.io.DataOutputStream;
                  
                  import net.minecraft.client.gui.GuiButton;
                  import net.minecraft.client.gui.GuiScreen;
                  import net.minecraft.client.resources.I18n;
                  import net.minecraft.entity.player.EntityPlayer;
                  import net.minecraft.item.Item;
                  import net.minecraft.item.ItemStack;
                  import net.minecraft.nbt.NBTTagCompound;
                  import net.minecraft.nbt.NBTTagList;
                  import net.minecraft.nbt.NBTTagString;
                  import net.minecraft.network.packet.Packet;
                  import net.minecraft.network.packet.Packet250CustomPayload;
                  import net.minecraft.util.ChatAllowedCharacters;
                  import net.minecraft.util.EnumChatFormatting;
                  import net.minecraft.util.ResourceLocation;
                  
                  import org.lwjgl.input.Keyboard;
                  import org.lwjgl.opengl.GL11;
                  
                  import cpw.mods.fml.relauncher.Side;
                  import cpw.mods.fml.relauncher.SideOnly;
                  
                  @SideOnly(Side.CLIENT)
                  public class guibook extends GuiScreen
                  {
                  private static final ResourceLocation bookGuiTextures = new ResourceLocation("textures/gui/book.png");
                  
                  /** The player editing the book */
                  private final EntityPlayer editingPlayer;
                  private final ItemStack itemstackBook;
                  
                  /** Whether the book is signed or can still be edited */
                  private final boolean bookIsUnsigned;
                  private boolean bookModified;
                  private boolean editingTitle;
                  
                  /** Update ticks since the gui was opened */
                  private int updateCount;
                  private int bookImageWidth = 192;
                  private int bookImageHeight = 192;
                  private int bookTotalPages = 1;
                  private int currPage;
                  private NBTTagList bookPages;
                  private String bookTitle = "";
                  private GuiButton buttonNextPage;
                  private GuiButton buttonPreviousPage;
                  private GuiButton buttonDone;
                  
                  /** The GuiButton to sign this book. */
                  private GuiButton buttonSign;
                  private GuiButton buttonFinalize;
                  private GuiButton buttonCancel;
                  
                  public guibook(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack, boolean par3)
                  {
                  this.editingPlayer = par1EntityPlayer;
                  this.itemstackBook = par2ItemStack;
                  this.bookIsUnsigned = par3;
                  
                  if (par2ItemStack.hasTagCompound())
                  {
                  NBTTagCompound nbttagcompound = par2ItemStack.getTagCompound();
                  this.bookPages = nbttagcompound.getTagList("pages");
                  
                  if (this.bookPages != null)
                  {
                  this.bookPages = (NBTTagList)this.bookPages.copy();
                  this.bookTotalPages = this.bookPages.tagCount();
                  
                  if (this.bookTotalPages < 1)
                  {
                  this.bookTotalPages = 1;
                  }
                  }
                  }
                  
                  if (this.bookPages == null && par3)
                  {
                  this.bookPages = new NBTTagList("pages");
                  this.bookPages.appendTag(new NBTTagString("1", ""));
                  this.bookTotalPages = 1;
                  }
                  }
                  
                  /**
                  * Called from the main game loop to update the screen.
                  */
                  public void updateScreen()
                  {
                  super.updateScreen();
                  ++this.updateCount;
                  }
                  
                  /**
                  * Adds the buttons (and other controls) to the screen in question.
                  */
                  public void initGui()
                  {
                  this.buttonList.clear();
                  Keyboard.enableRepeatEvents(true);
                  
                  if (this.bookIsUnsigned)
                  {
                  this.buttonList.add(this.buttonSign = new GuiButton(3, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.getString("book.signButton")));
                  this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.getString("gui.done")));
                  this.buttonList.add(this.buttonFinalize = new GuiButton(5, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.getString("book.finalizeButton")));
                  this.buttonList.add(this.buttonCancel = new GuiButton(4, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.getString("gui.cancel")));
                  }
                  else
                  {
                  this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 - 100, 4 + this.bookImageHeight, 200, 20, I18n.getString("gui.done")));
                  }
                  
                  int i = (this.width - this.bookImageWidth) / 2;
                  byte b0 = 2;
                  
                  this.updateButtons();
                  }
                  
                  /**
                  * Called when the screen is unloaded. Used to disable keyboard repeat events
                  */
                  public void onGuiClosed()
                  {
                  Keyboard.enableRepeatEvents(false);
                  }
                  
                  private void updateButtons()
                  {
                  this.buttonNextPage.drawButton = !this.editingTitle && (this.currPage < this.bookTotalPages - 1 || this.bookIsUnsigned);
                  this.buttonPreviousPage.drawButton = !this.editingTitle && this.currPage > 0;
                  this.buttonDone.drawButton = !this.bookIsUnsigned || !this.editingTitle;
                  
                  if (this.bookIsUnsigned)
                  {
                  this.buttonSign.drawButton = !this.editingTitle;
                  this.buttonCancel.drawButton = this.editingTitle;
                  this.buttonFinalize.drawButton = this.editingTitle;
                  this.buttonFinalize.enabled = this.bookTitle.trim().length() > 0;
                  }
                  }
                  
                  private void sendBookToServer(boolean par1)
                  {
                  if (this.bookIsUnsigned && this.bookModified)
                  {
                  if (this.bookPages != null)
                  {
                  while (this.bookPages.tagCount() > 1)
                  {
                  NBTTagString nbttagstring = (NBTTagString)this.bookPages.tagAt(this.bookPages.tagCount() - 1);
                  
                  if (nbttagstring.data != null && nbttagstring.data.length() != 0)
                  {
                  break;
                  }
                  
                  this.bookPages.removeTag(this.bookPages.tagCount() - 1);
                  }
                  
                  if (this.itemstackBook.hasTagCompound())
                  {
                  NBTTagCompound nbttagcompound = this.itemstackBook.getTagCompound();
                  nbttagcompound.setTag("pages", this.bookPages);
                  }
                  else
                  {
                  this.itemstackBook.setTagInfo("pages", this.bookPages);
                  }
                  
                  String s = "MC|BEdit";
                  
                  if (par1)
                  {
                  s = "MC|BSign";
                  this.itemstackBook.setTagInfo("author", new NBTTagString("author", this.editingPlayer.getCommandSenderName()));
                  this.itemstackBook.setTagInfo("title", new NBTTagString("title", this.bookTitle.trim()));
                  this.itemstackBook.itemID = Item.writtenBook.itemID;
                  }
                  
                  ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
                  DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
                  
                  try
                  {
                  Packet.writeItemStack(this.itemstackBook, dataoutputstream);
                  this.mc.getNetHandler().addToSendQueue(new Packet250CustomPayload(s, bytearrayoutputstream.toByteArray()));
                  }
                  catch (Exception exception)
                  {
                  exception.printStackTrace();
                  }
                  }
                  }
                  }
                  
                  /**
                  * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
                  */
                  protected void actionPerformed(GuiButton par1GuiButton)
                  {
                  if (par1GuiButton.enabled)
                  {
                  if (par1GuiButton.id == 0)
                  {
                  this.mc.displayGuiScreen((GuiScreen)null);
                  this.sendBookToServer(false);
                  }
                  else if (par1GuiButton.id == 3 && this.bookIsUnsigned)
                  {
                  this.editingTitle = true;
                  }
                  else if (par1GuiButton.id == 1)
                  {
                  if (this.currPage < this.bookTotalPages - 1)
                  {
                  ++this.currPage;
                  }
                  else if (this.bookIsUnsigned)
                  {
                  this.addNewPage();
                  
                  if (this.currPage < this.bookTotalPages - 1)
                  {
                  ++this.currPage;
                  }
                  }
                  }
                  else if (par1GuiButton.id == 2)
                  {
                  if (this.currPage > 0)
                  {
                  –this.currPage;
                  }
                  }
                  else if (par1GuiButton.id == 5 && this.editingTitle)
                  {
                  this.sendBookToServer(true);
                  this.mc.displayGuiScreen((GuiScreen)null);
                  }
                  else if (par1GuiButton.id == 4 && this.editingTitle)
                  {
                  this.editingTitle = false;
                  }
                  
                  this.updateButtons();
                  }
                  }
                  
                  private void addNewPage()
                  {
                  if (this.bookPages != null && this.bookPages.tagCount() < 50)
                  {
                  this.bookPages.appendTag(new NBTTagString("" + (this.bookTotalPages + 1), ""));
                  ++this.bookTotalPages;
                  this.bookModified = true;
                  }
                  }
                  
                  /**
                  * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
                  */
                  protected void keyTyped(char par1, int par2)
                  {
                  super.keyTyped(par1, par2);
                  
                  if (this.bookIsUnsigned)
                  {
                  if (this.editingTitle)
                  {
                  this.func_74162_c(par1, par2);
                  }
                  else
                  {
                  this.keyTypedInBook(par1, par2);
                  }
                  }
                  }
                  
                  /**
                  * Processes keystrokes when editing the text of a book
                  */
                  private void keyTypedInBook(char par1, int par2)
                  {
                  switch (par1)
                  {
                  case 22:
                  this.func_74160_b(GuiScreen.getClipboardString());
                  return;
                  default:
                  switch (par2)
                  {
                  case 14:
                  String s = this.func_74158_i();
                  
                  if (s.length() > 0)
                  {
                  this.func_74159_a(s.substring(0, s.length() - 1));
                  }
                  
                  return;
                  case 28:
                  case 156:
                  this.func_74160_b("\n");
                  return;
                  default:
                  if (ChatAllowedCharacters.isAllowedCharacter(par1))
                  {
                  this.func_74160_b(Character.toString(par1));
                  }
                  }
                  }
                  }
                  
                  private void func_74162_c(char par1, int par2)
                  {
                  switch (par2)
                  {
                  case 14:
                  if (!this.bookTitle.isEmpty())
                  {
                  this.bookTitle = this.bookTitle.substring(0, this.bookTitle.length() - 1);
                  this.updateButtons();
                  }
                  
                  return;
                  case 28:
                  case 156:
                  if (!this.bookTitle.isEmpty())
                  {
                  this.sendBookToServer(true);
                  this.mc.displayGuiScreen((GuiScreen)null);
                  }
                  
                  return;
                  default:
                  if (this.bookTitle.length() < 16 && ChatAllowedCharacters.isAllowedCharacter(par1))
                  {
                  this.bookTitle = this.bookTitle + Character.toString(par1);
                  this.updateButtons();
                  this.bookModified = true;
                  }
                  }
                  }
                  
                  private String func_74158_i()
                  {
                  if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount())
                  {
                  NBTTagString nbttagstring = (NBTTagString)this.bookPages.tagAt(this.currPage);
                  return nbttagstring.toString();
                  }
                  else
                  {
                  return "";
                  }
                  }
                  
                  private void func_74159_a(String par1Str)
                  {
                  if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount())
                  {
                  NBTTagString nbttagstring = (NBTTagString)this.bookPages.tagAt(this.currPage);
                  nbttagstring.data = par1Str;
                  this.bookModified = true;
                  }
                  }
                  
                  private void func_74160_b(String par1Str)
                  {
                  String s1 = this.func_74158_i();
                  String s2 = s1 + par1Str;
                  int i = this.fontRenderer.splitStringWidth(s2 + "" + EnumChatFormatting.BLACK + "_", 118);
                  
                  if (i <= 118 && s2.length() < 256)
                  {
                  this.func_74159_a(s2);
                  }
                  }
                  
                  /**
                  * Draws the screen and all the components in it.
                  */
                  public void drawScreen(int par1, int par2, float par3)
                  
                  {
                  
                  GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                  
                  if(this.currPage == 0)
                  
                  {
                  
                  this.mc.getTextureManager().bindTexture(bookGuiTextures);
                  
                  }
                  
                  else if(this.currPage == 1)
                  
                  {
                  
                  this.mc.getTextureManager().bindTexture(new ResourceLocation("PF", "textures/gui/image1.png"));
                  
                  }
                  
                  else if(this.currPage == 2)
                  
                  {
                  
                  this.mc.getTextureManager().bindTexture(new ResourceLocation("PF", "textures/gui/image2.png"));
                  
                  }
                  }
                  }
                  
                  
                  1 réponse Dernière réponse Répondre Citer 0
                  • M Hors-ligne
                    mrkevin77
                    dernière édition par

                    quelqu’un pour m’aider pour mon book

                    1 réponse Dernière réponse Répondre Citer 0
                    • isadorI Hors-ligne
                      isador Moddeurs confirmés Modérateurs
                      dernière édition par

                      quel est ton problème?

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

                        bah mon pb c que en fesant comme vous m’avez conseiller en utilisant le code du livre editable je n’arive toujour pas a faire mon livre personaliser avec mes image

                        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