MFF

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

    Baton et item de reparation et GUI

    Planifier Épinglé Verrouillé Déplacé Sans suite
    1.7.10
    41 Messages 7 Publieurs 7.8k 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.
    • YeyvoY Hors-ligne
      Yeyvo
      dernière édition par

      @‘Plaigon’:

      N’oublie pas la balise de la version au passage 😛

      Ensuite pour ton bâton de soin, recrée-toi un item où tu override la méthode onItemRightClick pour y ajouter un petit player.heal(4);//le nombre correspond aux nombres de demie coeurs à regen, donc 2 coeurs seront regen

      Ensuite pour le “durabilité minimal de 1”, je ne comprends pas tellement …
      Et sinon, j’ai pas test mais ton code pour ta première demande me semble bon à première vue :3

      je vien de changer le onrightclic par onUpdate

      la durabilite minimal de 1 servira a se que l’object ne se casse pas
        pour se que tu mas dit dans l’edit j’ai pas bien compris

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

        Pour ton baton de heal si tu veut te heal

        public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player)
        {
        
        player.addPotionEffect(new PotionEffect(Potion.heal.id, 60, 2));
        
        return item;
        }
        
        

        Essaye sa

        Si tu veut heal une autre personne:

        public boolean hitEntity(ItemStack item, EntityLivingBase attackedLiving, EntityLivingBase player)
           {
        
        attackedLiving.setHealth(20);
        
               return true;
           }
        

        Apres je c’est pas si c’est se que tu recherche.

        J’ai pas test le code

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

          Je le testerais mai j’y ajouterais un colldown genre 20seconde pour heal une autre perssogne j’esseyerai de fair une fleche comme celle de la 1.9
          T
          Pour heal une autre persogne je pourais utiliser une partie de ta fonction mais se ne sera pas un baton mais une fleche cimme ce

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

            
            @Override
            public void onUpdate(ItemStack item, World world, Entity player, int slotIndex, boolean inHand)
            {
            if(item.hasTagCompound())
            {
            if(item.stackTagCompound.getInteger("timer") > 0)
            {
            item.stackTagCompound.setInteger("timer", (int) (item.stackTagCompound.getInteger("timer") + 1));
            }
            if(item.stackTagCompound.getInteger("timer") >= (int) (18*20)) //Le 18 corespond au secondes
            {
            item.stackTagCompound.setInteger("timer", 0);
            }
            }
            super.onUpdate(item, world, player, slotIndex, inHand);
            }
            
            public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player)
            {
            if(!item.hasTagCompound())
            {
            item.setTagCompound(new NBTTagCompound());
            item.stackTagCompound.setInteger("timer", 0);
            }
            if(item.stackTagCompound.getInteger("timer") == 0)
            {
            player.heal(22);//22 est le nombre de demi coeur donc 11 coeur la
            //player.addPotionEffect(new PotionEffect(Potion.heal.id, 60, 2)); sinon tu peut utiliser une potion
            item.stackTagCompound.setInteger("timer", 1);
            }
            else
            {
            if(world.isRemote)
            player.addChatComponentMessage(new ChatComponentTranslation("Tu dois attendre que le sortilége se recharge !"));
            item.hasTagCompound();
            }
            return item;
            }
            
            @SideOnly(Side.CLIENT)
            public boolean hasEffect(ItemStack item)
            {
            return item.hasTagCompound() ? (item.stackTagCompound.getInteger("timer") == 0 ? true : false) : false;
            }
            
            }
            
            
            1 réponse Dernière réponse Répondre Citer 0
            • YeyvoY Hors-ligne
              Yeyvo
              dernière édition par

              Merci 🙂

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

                Ça ne sert à rien de faire une citation si vous répondez au message qui se trouve juste au dessus. Le seul effet que ça a c’est nuire à la lisibilité x)

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

                  @‘robin4002’:

                  Ça ne sert à rien de faire une citation si vous répondez au message qui se trouve juste au dessus. Le seul effet que ça a c’est nuire à la lisibilité x)

                  x) encore une citation  😛

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

                    Résolu sinon ?

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

                      @‘Plaigon’:

                      Résolu sinon  ?

                      Pas encore  😉

                      Ya t’il une onction pour un tp aleatoir dans un rayon defini ?? Si elle existe laquelle

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

                        Non il n’y en a pas, mais tu peux juste utiliser des randoms (en vérifiant que le bloc est de l’air)

                        Envoyé de mon RAINBOW LITE 4G en utilisant Tapatalk

                        Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                        AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                        Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                        Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

                          **Mercis pour l’info
                          **

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

                            Ah !!oui j’y pense si je veut que mon ring ne casse pas je fait comment

                            Je laisse 1de durabilité

                            Et sije veux qu’il soit réparable via un craft dans 
                            Ma machine a pala

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

                              Pourquoi souhaites-tu instaurer une dura a ton item si tu ne souhaites pas qu il se casse ? Sa n a pas de sens –’

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

                                **C’est pour quand le joueur veut le ré****parer il le réparé via une table spéciale dont le craft est 
                                **
                                **Assez cher
                                **Je vous les deja dis le 1de dura a pour but d’evité que l’objet disparaisse car il coute cher

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

                                  Eh bien si tu souhaites que ton item soit endommageable, mais incassable en gardant toujours 1 d’utilisation, je te conseille de cancel l’event PlayerDestroyItemEvent en ayant check avant si il s’agissait bien de ton item dont il est question. Apres avoir cancel l’event, je pense que ton item aura automatiquement gardé 1 de dura.

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

                                    Ou sinon plus simple si il te reste 1 de dura, tu empèche cette ligne de s’éxécuter dans ta fonction onItemRightClick : “stack.setItemDamage(stack.getItemDamage() + 1);”

                                    Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                                    AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                                    Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                                    Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

                                      Ouep effectivement une petite condition ternaire devrait faire l’affaire 😃

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

                                        j’ai reussi a pour le ring 
                                        mais quand j’ai ajoutté un gui et des recette mon jeux crash 
                                        Mes Logs:

                                        –-- Minecraft Crash Report ----
                                        
                                        // Who set us up the TNT?
                                        
                                        Time: 01/05/16 01:56
                                        Description: Initializing game
                                        
                                        java.lang.NullPointerException: Initializing game
                                        at cpw.mods.fml.common.network.NetworkRegistry.registerGuiHandler(NetworkRegistry.java:219)
                                        at ma.Yeyvo.Paladium.common.ModPaladium.init(ModPaladium.java:223)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                                        at java.lang.reflect.Method.invoke(Unknown Source)
                                        at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                                        at java.lang.reflect.Method.invoke(Unknown Source)
                                        at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
                                        at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
                                        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
                                        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
                                        at com.google.common.eventbus.EventBus.post(EventBus.java:275)
                                        at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
                                        at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                                        at java.lang.reflect.Method.invoke(Unknown Source)
                                        at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
                                        at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
                                        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
                                        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
                                        at com.google.common.eventbus.EventBus.post(EventBus.java:275)
                                        at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
                                        at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737)
                                        at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311)
                                        at net.minecraft.client.Minecraft.startGame(Minecraft.java:597)
                                        at net.minecraft.client.Minecraft.run(Minecraft.java:942)
                                        at net.minecraft.client.main.Main.main(Main.java:164)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                                        at java.lang.reflect.Method.invoke(Unknown Source)
                                        at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
                                        at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
                                        at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
                                        at GradleStart.main(Unknown Source)
                                        
                                        A detailed walkthrough of the error, its code path and all known details is as follows:
                                        ---------------------------------------------------------------------------------------
                                        
                                        -- Head --
                                        Stacktrace:
                                        at cpw.mods.fml.common.network.NetworkRegistry.registerGuiHandler(NetworkRegistry.java:219)
                                        at ma.Yeyvo.Paladium.common.ModPaladium.init(ModPaladium.java:223)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                                        at java.lang.reflect.Method.invoke(Unknown Source)
                                        at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                                        at java.lang.reflect.Method.invoke(Unknown Source)
                                        at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
                                        at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
                                        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
                                        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
                                        at com.google.common.eventbus.EventBus.post(EventBus.java:275)
                                        at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
                                        at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                                        at java.lang.reflect.Method.invoke(Unknown Source)
                                        at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
                                        at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
                                        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
                                        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
                                        at com.google.common.eventbus.EventBus.post(EventBus.java:275)
                                        at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
                                        at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737)
                                        at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311)
                                        at net.minecraft.client.Minecraft.startGame(Minecraft.java:597)
                                        
                                        -- Initialization --
                                        Details:
                                        Stacktrace:
                                        at net.minecraft.client.Minecraft.run(Minecraft.java:942)
                                        at net.minecraft.client.main.Main.main(Main.java:164)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                                        at java.lang.reflect.Method.invoke(Unknown Source)
                                        at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
                                        at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
                                        at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
                                        at GradleStart.main(Unknown Source)
                                        
                                        -- System Details --
                                        Details:
                                        Minecraft Version: 1.7.10
                                        Operating System: Windows 7 (x86) version 6.1
                                        Java Version: 1.8.0_91, Oracle Corporation
                                        Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
                                        Memory: 932285952 bytes (889 MB) / 1046937600 bytes (998 MB) up to 1046937600 bytes (998 MB)
                                        JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
                                        AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
                                        IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
                                        FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 4 mods loaded, 4 mods active
                                        States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
                                        UCHI mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
                                        UCHI FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) 
                                        UCHI Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) 
                                        UCHE paladium{1.0.0} [Paladium] (bin) 
                                        GL info: ' Vendor: 'Intel' Version: '3.1.0 - Build 9.17.10.3347' Renderer: 'Intel(R) HD Graphics 3000'
                                        Launched Version: 1.7.10
                                        LWJGL: 2.9.1
                                        OpenGL: Intel(R) HD Graphics 3000 GL version 3.1.0 - Build 9.17.10.3347, Intel
                                        GL Caps: Using GL 1.3 multitexturing.
                                        Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
                                        Anisotropic filtering is supported and maximum anisotropy is 16.
                                        Shaders are available because OpenGL 2.1 is supported.
                                        
                                        Is Modded: Definitely; Client brand changed to 'fml,forge'
                                        Type: Client (map_client.txt)
                                        Resource Packs: []
                                        Current Language: Français (France)
                                        Profiler Position: N/A (disabled)
                                        Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
                                        Anisotropic Filtering: Off (1)
                                        

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

                                          Sur ton instance, tu as mis “@Instance(“MODID”)”, et comme tu as mis MODID entre guillements, il considère que c’est l’instance du mod qui as comme modid “MODID” (qui n’est pas ton mod), il faut donc que tu mettes le modid de ton mod, en retirant les guillements.

                                          Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                                          AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                                          Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                                          Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

                                            Mes texture et mon Gui ne s’afiche pas dans minecraft par contre les recettes et les slots oui

                                            #MachinePala (MachinePala )

                                            import ma.Yeyvo.Paladium.common.ModPaladium;
                                            import net.minecraft.block.Block;
                                            import net.minecraft.block.BlockContainer;
                                            import net.minecraft.block.material.Material;
                                            import net.minecraft.client.renderer.texture.IIconRegister;
                                            import net.minecraft.creativetab.CreativeTabs;
                                            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.IIcon;
                                            import net.minecraft.world.World;
                                            
                                            public class MachinePala extends BlockContainer
                                            {
                                                public MachinePala()
                                                {
                                                    super(Material.rock);
                                                    setResistance(8F);
                                                    setHarvestLevel("pickaxe", 2);
                                                    setCreativeTab(CreativeTabs.tabBlock);
                                                    setHardness(8F);
                                                }
                                                public TileEntity createNewTileEntity(World world, int metadata)
                                                {
                                                    return new TileEntityMachinePala();
                                                }
                                                public boolean hasTileEntity(int metadata)
                                                {
                                                    return true;
                                                }
                                            
                                                public void breakBlock(World world, int x, int y, int z, Block block, int metadata)
                                                {
                                                    TileEntity tileentity = world.getTileEntity(x, y, z);
                                                    if(tileentity instanceof IInventory)
                                                    {
                                                        IInventory inv = (IInventory)tileentity;
                                                        for(int i1 = 0; i1 < inv.getSizeInventory(); i1++)
                                                        {
                                                            ItemStack itemstack = inv.getStackInSlot(i1);
                                                            if(itemstack == null)
                                                                continue;
                                                            float f = world.rand.nextFloat() * 0.8F + 0.1F;
                                                            float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
                                                            float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
                                                            while(itemstack.stackSize > 0) 
                                                            {
                                                                int j1 = world.rand.nextInt(21) + 10;
                                                                if(j1 > itemstack.stackSize)
                                                                    j1 = itemstack.stackSize;
                                                                itemstack.stackSize -= j1;
                                                                EntityItem entityitem = new EntityItem(world, (float)x + f, (float)y + f1, (float)z + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
                                                                float f3 = 0.05F;
                                                                entityitem.motionX = (float)world.rand.nextGaussian() * f3;
                                                                entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F;
                                                                entityitem.motionZ = (float)world.rand.nextGaussian() * f3;
                                                                if(itemstack.hasTagCompound())
                                                                    entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                                                                world.spawnEntityInWorld(entityitem);
                                                            }
                                                        }
                                            
                                                        world.func_147453_f(x, y, z, block);
                                                    }
                                                    super.breakBlock(world, x, y, z, block, metadata);
                                                }
                                            
                                                public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
                                                {
                                                    if(world.isRemote)
                                                    {
                                                        return true;
                                                    } else
                                                    {
                                                        player.openGui(ModPaladium.instance, 0, world, x, y, z);
                                                        return true;
                                                    }
                                                }
                                            
                                                public void registerIcons(IIconRegister iiconRegister)
                                                {
                                                blockIcon = iiconRegister.registerIcon(ModPaladium.MODID + ":cote");
                                                    top = iiconRegister.registerIcon(ModPaladium.MODID + ":haut");
                                                    bottom = iiconRegister.registerIcon(ModPaladium.MODID + ":cote");
                                                }
                                            
                                                public IIcon getIcon(int side, int metadata)
                                                {
                                                if(side == 0)
                                                {
                                                return this.bottom;
                                                }
                                                else if(side == 1)
                                                {
                                                return this.top;
                                                }
                                                    return this.blockIcon;
                                                }
                                            
                                                IIcon icontop;
                                                private IIcon iconbottom;
                                                private IIcon top;
                                                private IIcon bottom;
                                            }
                                            

                                            #GuiMachine (GuiMachine )

                                            import org.lwjgl.opengl.GL11;
                                            
                                            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;
                                            
                                            public class GuiMachine extends GuiContainer
                                            {
                                            
                                                public GuiMachine(TileEntityMachinePala tile, InventoryPlayer inventory)
                                                {
                                                    super(new ContainerMachine(tile, inventory));
                                                    tileCompressor = tile;
                                                    playerInv = inventory;
                                                    allowUserInput = true;
                                                    ySize = 340;
                                                    xSize = 200;
                                                }
                                            
                                                protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y)
                                                {
                                                    GL11.glColor4f(1.0F, 1.5F, 1.0F, 1.0F);
                                                    mc.getTextureManager().bindTexture(GuiPaladium);
                                                    int k = (width - xSize) / 2;
                                                    int l = (height - ySize) / 2;
                                                    drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
                                                    if(tileCompressor.isBurning())
                                                    {
                                                        int i = tileCompressor.getCookProgress();
                                                        drawTexturedModalRect(k + 90, l + 122, 201, 105, 20, i);
                                                    }
                                                }
                                            
                                                protected void drawGuiContainerForegroundLayer(int x, int y)
                                                {
                                                fontRendererObj.drawString(playerInv.hasCustomInventoryName() ? playerInv.getInventoryName() : I18n.format(playerInv.getInventoryName(), new Object[0]), 15, ySize - 180, 0x404040);
                                                }
                                            
                                                private static final ResourceLocation GuiPaladium = new ResourceLocation("textures/gui/container/GuiPaladium.png");
                                                private TileEntityMachinePala tileCompressor;
                                                private IInventory playerInv;
                                            
                                            }
                                            
                                            

                                            #ContainerMachine (ContainerMachine )

                                            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;
                                            
                                            public class ContainerMachine extends Container
                                            {
                                            
                                                public ContainerMachine(TileEntityMachinePala tile, InventoryPlayer inventory)
                                                {
                                                    tileMachinePala = tile;
                                                    addSlotToContainer(new Slot(tile, 0, 89, 95));
                                                    addSlotToContainer(new Slot(tile, 1, 25, 103));
                                                    addSlotToContainer(new Slot(tile, 2, 53, 123));
                                                    addSlotToContainer(new Slot(tile, 3, 153, 103));
                                                    addSlotToContainer(new Slot(tile, 4, 125, 123));
                                                    addSlotToContainer(new SlotResulte(tile, 5, 89, 146));
                                                    bindPlayerInventory(inventory);
                                                }
                                            
                                                public boolean canInteractWith(EntityPlayer player)
                                                {
                                                    return tileMachinePala.isUseableByPlayer(player);
                                                }
                                            
                                                private void bindPlayerInventory(InventoryPlayer inventory)
                                                {
                                                    for(int i = 0; i < 3; i++)
                                                    {
                                                        for(int j = 0; j < 9; j++)
                                                        addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 17 + j * 18, 171 + i * 18));
                                            
                                                    }
                                            
                                                    for(int i = 0; i < 9; i++)
                                                    addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 229));
                                            
                                                }
                                            
                                                public ItemStack transferStackInSlot(EntityPlayer player, int quantity)
                                                {
                                                    ItemStack itemstack = null;
                                                    Slot slot = (Slot)inventorySlots.get(quantity);
                                                    if(slot != null && slot.getHasStack())
                                                    {
                                                        ItemStack itemstack1 = slot.getStack();
                                                        itemstack = itemstack1.copy();
                                                        if(quantity < tileMachinePala.getSizeInventory())
                                                        {
                                                            if(!mergeItemStack(itemstack1, tileMachinePala.getSizeInventory(), inventorySlots.size(), true))
                                                                return null;
                                                        } else
                                                        if(!mergeItemStack(itemstack1, 0, tileMachinePala.getSizeInventory(), false))
                                                            return null;
                                                        if(itemstack1.stackSize == 0)
                                                            slot.putStack((ItemStack)null);
                                                        else
                                                            slot.onSlotChanged();
                                                    }
                                                    return itemstack;
                                                }
                                            
                                                public void onContainerClosed(EntityPlayer player)
                                                {
                                                    super.onContainerClosed(player);
                                                    tileMachinePala.closeInventory();
                                                }
                                            
                                                private TileEntityMachinePala tileMachinePala;
                                            }
                                            
                                            

                                            #GuiHandler(GuiHandler)

                                            import cpw.mods.fml.common.network.IGuiHandler;
                                            import net.minecraft.entity.player.EntityPlayer;
                                            import net.minecraft.tileentity.TileEntity;
                                            import net.minecraft.world.World;
                                            
                                            public class GuiHandler
                                                implements IGuiHandler
                                            {
                                            
                                                public GuiHandler()
                                                {
                                                }
                                            
                                                public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
                                                {
                                                    TileEntity tile = world.getTileEntity(x, y, z);
                                                    if(tile instanceof TileEntityMachinePala)
                                                        return new ContainerMachine((TileEntityMachinePala)tile, player.inventory);
                                                    else
                                                        return null;
                                                }
                                            
                                                public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
                                                {
                                                    TileEntity tile = world.getTileEntity(x, y, z);
                                                    if(tile instanceof TileEntityMachinePala)
                                                        return new GuiMachine((TileEntityMachinePala)tile, player.inventory);
                                                    else
                                                        return null;
                                                }
                                            }
                                            

                                            #TileEntityMachinePala (TileEntityMachinePala )

                                            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;
                                            
                                            public class TileEntityMachinePala extends TileEntity
                                            implements IInventory
                                            {
                                            
                                                public TileEntityMachinePala()
                                                {
                                                    contents = new ItemStack[6];
                                                    workingTime = 0;
                                                    workingTimeNeeded = 200;
                                                }
                                                @Override
                                                public void writeToNBT(NBTTagCompound compound)
                                                {
                                                super.writeToNBT(compound);
                                                    NBTTagList nbttaglist = new NBTTagList();
                                                    for(int i = 0; i < contents.length; i++)
                                                        if(contents* != null)
                                                        {
                                                            NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                                                            nbttagcompound1.setByte("Slot", (byte)i);
                                                            contents*.writeToNBT(nbttagcompound1);
                                                            nbttaglist.appendTag(nbttagcompound1);
                                                        }
                                            
                                                    compound.setTag("Items", nbttaglist);
                                                    compound.setShort("workingTime", (short)workingTime);
                                                    compound.setShort("workingTimeNeeded", (short)workingTimeNeeded);
                                                }
                                            
                                                public int getCookProgress()
                                                {
                                                    return (workingTime * 16) / workingTimeNeeded;
                                                }
                                                @Override
                                                public void readFromNBT(NBTTagCompound compound)
                                                {
                                                    super.readFromNBT(compound);
                                                    NBTTagList nbttaglist = compound.getTagList("Items", 10);
                                                    contents = new ItemStack[getSizeInventory()];
                                                    for(int i = 0; i < nbttaglist.tagCount(); i++)
                                                    {
                                                        NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                                                        int j = nbttagcompound1.getByte("Slot");
                                                        if(j >= 0 && j < contents.length)
                                                            contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                                                    }
                                            
                                                    workingTime = compound.getShort("workingTime");
                                                    workingTimeNeeded = compound.getShort("workingTimeNeeded");
                                                }
                                                @Override
                                                public int getSizeInventory()
                                                {
                                                    return contents.length;
                                                }
                                                @Override
                                                public ItemStack getStackInSlot(int slotIndex)
                                                {
                                                    return contents[slotIndex];
                                                }
                                                @Override
                                                public ItemStack decrStackSize(int slotIndex, int amount)
                                                {
                                                    if(contents[slotIndex] != null)
                                                    {
                                                        ItemStack itemstack;
                                                        if(contents[slotIndex].stackSize <= amount)
                                                        {
                                                            itemstack = contents[slotIndex];
                                                            contents[slotIndex] = null;
                                                            markDirty();
                                                            return itemstack;
                                                        }
                                                        itemstack = contents[slotIndex].splitStack(amount);
                                                        if(contents[slotIndex].stackSize == 0)
                                                            contents[slotIndex] = null;
                                                        markDirty();
                                                        return itemstack;
                                                    } else
                                                    {
                                                        return null;
                                                    }
                                                }
                                                @Override
                                                public ItemStack getStackInSlotOnClosing(int slotIndex)
                                                {
                                                    if(contents[slotIndex] != null)
                                                    {
                                                        ItemStack itemstack = contents[slotIndex];
                                                        contents[slotIndex] = null;
                                                        return itemstack;
                                                    } else
                                                    {
                                                        return null;
                                                    }
                                                }
                                                @Override
                                                public void setInventorySlotContents(int slotIndex, ItemStack stack)
                                                {
                                                    contents[slotIndex] = stack;
                                                    if(stack != null && stack.stackSize > getInventoryStackLimit())
                                                        stack.stackSize = getInventoryStackLimit();
                                                    markDirty();
                                                }
                                                @Override
                                                public String getInventoryName()
                                                {
                                                    return "tile.Machinetuto";
                                                }
                                                @Override
                                                public boolean hasCustomInventoryName()
                                                {
                                                    return false;
                                                }
                                                @Override
                                                public int getInventoryStackLimit()
                                                {
                                                    return 64;
                                                }
                                                @Override
                                                public boolean isUseableByPlayer(EntityPlayer player)
                                                {
                                                    return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this ? player.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64D : false;
                                                }
                                                @Override
                                                public void openInventory()
                                                {
                                                }
                                                @Override
                                                public void closeInventory()
                                                {
                                                }
                                                @Override
                                                public boolean isItemValidForSlot(int slot, ItemStack stack)
                                                {
                                                    return slot != 5;
                                                }
                                            
                                                public boolean isBurning()
                                                {
                                                    return workingTime > 0;
                                                }
                                            
                                                private boolean canSmelt()
                                                {
                                                    if(contents[0] == null || contents[1] == null || contents[2] == null || contents[3] == null || contents[4] == null)
                                                        return false;
                                                    ItemStack itemstack = MachineRecipes.smelting().getSmeltingResult(new ItemStack[] {
                                                        contents[0], contents[1], contents[2], contents[3], contents[4]
                                                    });
                                                    if(itemstack == null)
                                                        return false;
                                                    if(contents[5] == null)
                                                        return true;
                                                    if(!contents[5].isItemEqual(itemstack))
                                                    {
                                                        return false;
                                                    } else
                                                    {
                                                        int result = contents[5].stackSize + itemstack.stackSize;
                                                        return result <= getInventoryStackLimit() && result <= contents[5].getMaxStackSize();
                                                    }
                                                }
                                            
                                                public void updateEntity()
                                                {
                                                    if(isBurning() && canSmelt())
                                                        workingTime++;
                                                    if(canSmelt() && !isBurning())
                                                        workingTime = 1;
                                                    if(canSmelt() && workingTime == workingTimeNeeded)
                                                    {
                                                        smeltItem();
                                                        workingTime = 0;
                                                    }
                                                    if(!canSmelt())
                                                        workingTime = 0;
                                                }
                                            
                                                public void smeltItem()
                                                {
                                                    if(canSmelt())
                                                    {
                                                        ItemStack itemstack = MachineRecipes.smelting().getSmeltingResult(new ItemStack[] {
                                                            contents[0], contents[1], contents[2], contents[3], contents[4]
                                                        });
                                                        if(contents[5] == null)
                                                            contents[5] = itemstack.copy();
                                                        else
                                                        if(contents[5].getItem() == itemstack.getItem())
                                                            contents[5].stackSize += itemstack.stackSize;
                                                        contents[0].stackSize–;
                                                        contents[1].stackSize–;
                                                        contents[2].stackSize–;
                                                        contents[3].stackSize–;
                                                        contents[4].stackSize–;
                                                        if(contents[0].stackSize <= 0)
                                                            contents[0] = null;
                                                        if(contents[1].stackSize <= 0)
                                                            contents[1] = null;
                                                        if(contents[2].stackSize <= 0)
                                                            contents[2] = null;
                                                        if(contents[3].stackSize <= 0)
                                                            contents[3] = null;
                                                        if(contents[4].stackSize <= 0)
                                                            contents[4] = null;
                                                    }
                                                }
                                            
                                                private ItemStack contents[];
                                                private int workingTime;
                                                private int workingTimeNeeded;
                                            
                                            }
                                            
                                            [font=monospace**#SlotResulte(SlotResulte)**]
                                            
                                            
                                            import net.minecraft.entity.player.EntityPlayer;
                                            import net.minecraft.inventory.IInventory;
                                            import net.minecraft.inventory.Slot;
                                            import net.minecraft.item.ItemStack;
                                            
                                            public class SlotResulte extends Slot
                                            {
                                            
                                                public SlotResulte(IInventory inventory, int id, int x, int y)
                                                {
                                                    super(inventory, id, x, y);
                                                }
                                            
                                                public boolean isItemValid(ItemStack stack)
                                                {
                                                    return false;
                                                }
                                            
                                                public ItemStack decrStackSize(int amount)
                                                {
                                                    return super.decrStackSize(amount);
                                                }
                                            
                                                public void onPickupFromSlot(EntityPlayer player, ItemStack stack)
                                                {
                                                    super.onCrafting(stack);
                                                    super.onPickupFromSlot(player, stack);
                                                }
                                            }
                                            
                                            

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

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB