MFF

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

    RenderItem

    Planifier Épinglé Verrouillé Déplacé Non résolu Sans suite
    1.12.2
    24 Messages 2 Publieurs 1.5k Vues 2 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.
    • AsonyxA Hors-ligne
      Asonyx
      dernière édition par

      Tu peux m’envoyer ta class principale ?

      D 1 réponse Dernière réponse Répondre Citer 0
      • D Hors-ligne
        Drastic @Asonyx
        dernière édition par

        @Asonyx ok

        package com.avonia.mod;
        
        import com.avonia.mod.proxy.CommonProxy;
        import com.avonia.mod.util.Reference;
        import com.avonia.mod.util.handlers.RegistryHandler;
        
        import ca.weblite.objc.Client;
        import net.minecraft.creativetab.CreativeTabs;
        import net.minecraft.entity.player.EntityPlayer;
        import net.minecraftforge.event.entity.living.LivingDamageEvent;
        import net.minecraftforge.fml.common.Mod;
        import net.minecraftforge.fml.common.Mod.EventHandler;
        import net.minecraftforge.fml.common.Mod.Instance;
        import net.minecraftforge.fml.common.SidedProxy;
        import net.minecraftforge.fml.common.event.FMLInitializationEvent;
        import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
        import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
        import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
        
        @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION)
        public class Main
        {
            @Instance
            public static Main instance;
                
            @SidedProxy(clientSide = Reference.CLIENT, serverSide = Reference.COMMON)
            public static CommonProxy proxy;
        
            @EventHandler
            public static void preInit(FMLPreInitializationEvent e)
            {
                RegistryHandler.preInitRegistries();
            }
            
            @EventHandler
            public static void init(FMLInitializationEvent e)
            {         
                RegistryHandler.initRegistries();
            }
            
            @EventHandler
            public static void postInit(FMLPostInitializationEvent e)
            {
            }
            
        }
        
        

        Registrhandler :

        /*
         * Minecraft Forge
         * Copyright (c) 2016-2018.
         *
         * This library is free software; you can redistribute it and/or
         * modify it under the terms of the GNU Lesser General Public
         * License as published by the Free Software Foundation version 2.1
         * of the License.
         *
         * This library is distributed in the hope that it will be useful,
         * but WITHOUT ANY WARRANTY; without even the implied warranty of
         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
         * Lesser General Public License for more details.
         *
         * You should have received a copy of the GNU Lesser General Public
         * License along with this library; if not, write to the Free Software
         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
         */
        
        package net.minecraftforge.event;
        
        import java.util.Collection;
        import java.util.stream.Collectors;
        
        import org.apache.commons.lang3.Validate;
        
        import com.google.common.collect.ImmutableList;
        import net.minecraft.util.ResourceLocation;
        import net.minecraftforge.fml.common.ModContainer;
        import net.minecraftforge.fml.common.eventhandler.Event;
        import net.minecraftforge.fml.common.eventhandler.GenericEvent;
        import net.minecraftforge.fml.common.eventhandler.IContextSetter;
        import net.minecraftforge.registries.IForgeRegistry;
        import net.minecraftforge.registries.IForgeRegistryEntry;
        
        
        /**
         * RegistryEvent supertype.
         */
        public class RegistryEvent<T extends IForgeRegistryEntry<T>> extends GenericEvent<T> implements IContextSetter
        {
            RegistryEvent(Class<T> clazz) {
                super(clazz);
            }
            /**
             * Register new registries when you receive this event, through the {@link RecipeBuilder}
             */
            public static class NewRegistry extends Event
            {
            }
        
            /**
             * Register your objects for the appropriate registry type when you receive this event.
             *
             * <code>event.getRegistry().register(...)</code>
             *
             * The registries will be visited in alphabetic order of their name, except blocks and items,
             * which will be visited FIRST and SECOND respectively.
             *
             * ObjectHolders will reload between Blocks and Items, and after all registries have been visited.
             * @param <T> The registry top level type
             */
            public static class Register<T extends IForgeRegistryEntry<T>> extends RegistryEvent<T>
            {
                private final IForgeRegistry<T> registry;
                private final ResourceLocation name;
        
                public Register(ResourceLocation name, IForgeRegistry<T> registry)
                {
                    super(registry.getRegistrySuperType());
                    this.name = name;
                    this.registry = registry;
                }
        
                public IForgeRegistry<T> getRegistry()
                {
                    return registry;
                }
        
                public ResourceLocation getName()
                {
                    return name;
                }
        
            }
        
            public static class MissingMappings<T extends IForgeRegistryEntry<T>> extends RegistryEvent<T>
            {
                private final IForgeRegistry<T> registry;
                private final ResourceLocation name;
                private final ImmutableList<Mapping<T>> mappings;
                private ModContainer activeMod;
        
                public MissingMappings(ResourceLocation name, IForgeRegistry<T> registry, Collection<Mapping<T>> missed)
                {
                    super(registry.getRegistrySuperType());
                    this.registry = registry;
                    this.name = name;
                    this.mappings = ImmutableList.copyOf(missed);
                }
        
                public void setModContainer(ModContainer mod)
                {
                    this.activeMod = mod;
                }
        
                public ResourceLocation getName()
                {
                    return this.name;
                }
        
                public IForgeRegistry<T> getRegistry()
                {
                    return this.registry;
                }
        
                public ImmutableList<Mapping<T>> getMappings()
                {
                    return ImmutableList.copyOf(this.mappings.stream().filter(e -> e.key.getResourceDomain().equals(this.activeMod.getModId())).collect(Collectors.toList()));
                }
        
                public ImmutableList<Mapping<T>> getAllMappings()
                {
                    return this.mappings;
                }
        
                /**
                 * Actions you can take with this missing mapping.
                 * <ul>
                 * <li>{@link #IGNORE} means this missing mapping will be ignored.
                 * <li>{@link #WARN} means this missing mapping will generate a warning.
                 * <li>{@link #FAIL} means this missing mapping will prevent the world from loading.
                 * </ul>
                 */
                public enum Action
                {
                    /**
                     * Take the default action
                     */
                    DEFAULT,
                    /**
                     * Ignore this missing mapping. This means the mapping will be abandoned
                     */
                    IGNORE,
                    /**
                     * Generate a warning but allow loading to continue
                     */
                    WARN,
                    /**
                     * Fail to load
                     */
                    FAIL,
                    /**
                     * Remap this name to a new name (add a migration mapping)
                     */
                    REMAP
                }
        
                public static class Mapping<T extends IForgeRegistryEntry<T>>
                {
                    public final IForgeRegistry<T> registry;
                    private final IForgeRegistry<T> pool;
                    public final ResourceLocation key;
                    public final int id;
                    private Action action = Action.DEFAULT;
                    private T target;
        
                    public Mapping(IForgeRegistry<T> registry, IForgeRegistry<T> pool, ResourceLocation key, int id)
                    {
                        this.registry = registry;
                        this.pool = pool;
                        this.key = key;
                        this.id = id;
                    }
        
                    /**
                     * Ignore the missing item.
                     */
                    public void ignore()
                    {
                        action = Action.IGNORE;
                    }
        
                    /**
                     * Warn the user about the missing item.
                     */
                    public void warn()
                    {
                        action = Action.WARN;
                    }
        
                    /**
                     * Prevent the world from loading due to the missing item.
                     */
                    public void fail()
                    {
                        action = Action.FAIL;
                    }
        
                    /**
                     * Remap the missing entry to the specified object.
                     *
                     * Use this if you have renamed an entry.
                     * Existing references using the old name will point to the new one.
                     *
                     * @param target Entry to remap to.
                     */
                    public void remap(T target)
                    {
                        Validate.notNull(target, "Remap target can not be null");
                        Validate.isTrue(pool.getKey(target) != null, String.format("The specified entry %s hasn't been registered in registry yet.", target));
                        action = Action.REMAP;
                        this.target = target;
                    }
        
                    // internal
                    public Action getAction()
                    {
                        return this.action;
                    }
        
                    public T getTarget()
                    {
                        return target;
                    }
                }
            }
        }
        
        1 réponse Dernière réponse Répondre Citer 0
        • AsonyxA Hors-ligne
          Asonyx
          dernière édition par

          Tu m’a envoyer la class RegistryEvent…
          Alors que ta class c’est RegisterHandler

          D 1 réponse Dernière réponse Répondre Citer 0
          • D Hors-ligne
            Drastic @Asonyx
            dernière édition par

            @Asonyx Ah rip

            package com.avonia.mod.util.handlers;
            
            import com.avonia.mod.Main;
            import com.avonia.mod.init.BlockInit;
            import com.avonia.mod.init.EntityInit;
            import com.avonia.mod.init.ItemInit;
            import com.avonia.mod.util.IHasModel;
            import com.avonia.mod.util.Reference;
            
            import net.minecraft.block.Block;
            import net.minecraft.item.Item;
            import net.minecraft.util.ResourceLocation;
            import net.minecraftforge.client.event.ModelRegistryEvent;
            import net.minecraftforge.common.MinecraftForge;
            import net.minecraftforge.event.RegistryEvent;
            import net.minecraftforge.fml.client.registry.ClientRegistry;
            import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
            import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
            import net.minecraftforge.fml.common.network.NetworkRegistry;
            import net.minecraftforge.fml.relauncher.Side;
            import net.minecraftforge.fml.relauncher.SideOnly;
            
            @EventBusSubscriber
            public class RegistryHandler
            {
                @SubscribeEvent
                public static void onItemRegister(RegistryEvent.Register<Item> event)
                {
                    event.getRegistry().registerAll(ItemInit.ITEMS.toArray(new Item[0]));
                }
                
                @SubscribeEvent
                public static void onBlockRegister(RegistryEvent.Register<Block> event)
                {
                    event.getRegistry().registerAll(BlockInit.BLOCKS.toArray(new Block[0]));
                    TileEntityHandler.registerTileEntities();
                }
                
                @SubscribeEvent
                public static void onModelRegister(ModelRegistryEvent event)
                {
                    
                    for(Item item : ItemInit.ITEMS)
                    {
                        if(item instanceof IHasModel)
                        {
                            ((IHasModel)item).registerModels();
                        }
                    }
                    
                    for(Block block : BlockInit.BLOCKS)
                    {
                        if(block instanceof IHasModel)
                        {
                            ((IHasModel)block).registerModels();
                        }
                    }
                }
                
                public static void preInitRegistries()
                {
                    EntityInit.registerEntities();
                    RenderHandler.registerEntityRenders();
                }
               
                public static void initRegistries()
                {
            
                }
            }
            
            1 réponse Dernière réponse Répondre Citer 0
            • AsonyxA Hors-ligne
              Asonyx
              dernière édition par

              Les entitées doivent être dans la méthode init, alors que tu l’as mis dans preInit

              D 1 réponse Dernière réponse Répondre Citer 1
              • D Hors-ligne
                Drastic @Asonyx
                dernière édition par

                @Asonyx ah ok

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

                  @Asonyx re, désolé de te redéranger ,mais, je voudrais que l’entité n’explose que si elle atterrit sur un bloc. Comment faire ?
                  Merci

                  public EntityDyna(World worldIn)
                      {
                          super(worldIn);
                      }
                  
                      public EntityDyna(World worldIn, EntityLivingBase throwerIn)
                      {
                          super(worldIn, throwerIn);
                      }
                  
                      public EntityDyna(World worldIn, double x, double y, double z)
                      {
                          super(worldIn, x, y, z);
                      }
                  
                      public static void registerFixesSnowball(DataFixer fixer)
                      {
                          EntityThrowable.registerFixesThrowable(fixer, "Snowball");
                      }
                  
                      /**
                       * Handler for {@link World#setEntityState}
                       */
                      @SideOnly(Side.CLIENT)
                      public void handleStatusUpdate(byte id)
                      {
                          if (id == 3)
                          {
                              for (int i = 0; i < 8; ++i)
                              {
                                  this.world.spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
                              }
                          }
                      }
                  
                      /**
                       * Called when this EntityThrowable hits a block or entity.
                       */
                      protected void onImpact(RayTraceResult result)
                      {
                          if (result.entityHit != null)
                          {
                              int i = 0;
                  
                              if (result.entityHit instanceof EntityBlaze)
                              {
                                  i = 3;
                              }
                              
                              result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)i);
                              world.createExplosion(this, this.posX, this.posY, this.posZ, 4.0F, true);
                              this.setDead();
                          }
                  
                          if (!this.world.isRemote)
                          {
                              this.world.setEntityState(this, (byte)3);
                              this.setDead();
                          }
                      }
                  
                  1 réponse Dernière réponse Répondre Citer 0
                  • AsonyxA Hors-ligne
                    Asonyx
                    dernière édition par Asonyx

                    Normalement, dans onImpact, tu peut utiliser une fonction qui s’appelle je crois isOnGround() qui retourne un boolean (je ne suis pas sûr)
                    Ou une fontion de result

                    D 1 réponse Dernière réponse Répondre Citer 0
                    • D Hors-ligne
                      Drastic @Asonyx
                      dernière édition par

                      @Asonyx yas inGround et onGround mais aucun ne va.

                      1 réponse Dernière réponse Répondre Citer -1
                      • AsonyxA Hors-ligne
                        Asonyx
                        dernière édition par

                        Sinon tu vérifie si l’entité touchée est null

                        D 1 réponse Dernière réponse Répondre Citer 0
                        • D Hors-ligne
                          Drastic @Asonyx
                          dernière édition par

                          @Asonyx Comment ca ?

                          1 réponse Dernière réponse Répondre Citer -1
                          • AsonyxA Hors-ligne
                            Asonyx
                            dernière édition par

                            Tu fais :

                            if (result.entityHit == null) {
                                    //Le code quand la dynamite touche le sol
                            }
                            
                            1 réponse Dernière réponse Répondre Citer 0
                            • D Hors-ligne
                              Drastic
                              dernière édition par

                              @Asonyx a dit dans RenderItem :

                              if (result.entityHit == null) { //Le code quand la dynamite touche le sol }

                              toujours pas…

                              if (result.entityHit.equals(null)) 
                                          {
                                                  world.createExplosion(this, this.posX, this.posY, this.posZ, 1.5F, true);
                                                  this.setDead();                    
                                          }
                              
                              1 réponse Dernière réponse Répondre Citer 0
                              • AsonyxA Hors-ligne
                                Asonyx
                                dernière édition par

                                Et ça :

                                if (result.entityHit != null) {
                                }
                                else {
                                    //Le code
                                }
                                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