1.12.2 RenderItem



  • Bonjour, je cherche à faire une entité qui extends l'entityThrowable mais, pour le rendu, je n'y arrive pas.
    Je ne sais pas quoi mettre pour initialiser la variable "itemRender" (classe RenderHandler).

    Mon code :

    RenderDyna :

    @SideOnly(Side.CLIENT)
    public class RenderDyna extends RenderSnowball<EntityDyna>
    {
    
        public RenderDyna(RenderManager renderManagerIn, Item itemIn, RenderItem itemRendererIn)
        {
            super(renderManagerIn, itemIn, itemRendererIn);
        }  
    }
    

    EntityDyna :

    public class EntityDyna extends EntityThrowable
    {
    
        public EntityDyna(World worldIn)
        {
            super(worldIn);
        }
    
        @Override
        protected void onImpact(RayTraceResult result)
        {
            if(!world.isRemote)
            {
                world.createExplosion(this, this.posX, this.posY, this.posZ, 4.0F, true);
                this.setDead();
            }
        }
    
    }
    

    RenderHandler :

    public class RenderHandler
    {
        
        private static RenderItem itemRender;
        
        public static void registerEntityRenders()
        {
            RenderingRegistry.registerEntityRenderingHandler(EntityDyna.class, new IRenderFactory<EntityDyna>() 
            {
                @Override
                public Render<? super EntityDyna> createRenderFor(RenderManager manager)
                {
                    return new RenderDyna(manager, Items.SNOWBALL, itemRender);
                }
            });
        }
    }
    
    


  • Pour initialiser la variable itemRender (de type RenderItem), tu doit utiliser la methode getRenderItem() de Minecraft :

    Minecraft.getMinecraft().getRenderItem()
    


  • @Asonyx
    Merci mais le probleme persiste...

    crash report :

    Description: Rendering entity in world
    
    java.lang.NullPointerException: Rendering entity in world
       at com.avonia.mod.renderer.entity.RenderDyna.doRender(RenderDyna.java:51)
       at net.minecraft.client.renderer.entity.RenderManager.renderEntity(RenderManager.java:390)
       at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:374)
       at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:655)
       at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1400)
       at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1312)
       at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1115)
       at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1209)
       at net.minecraft.client.Minecraft.run(Minecraft.java:442)
       at net.minecraft.client.main.Main.main(Main.java:118)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
       at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
       at GradleStart.main(GradleStart.java:25)
    

    Le reste du code n'a pas changé à part le

        private static RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
    


  • @Asonyx mauvais c-r.
    Le bon :

    java.lang.NullPointerException: Rendering entity in world
    	at net.minecraft.client.renderer.entity.RenderSnowball.doRender(RenderSnowball.java:46)
    	at net.minecraft.client.renderer.entity.RenderManager.renderEntity(RenderManager.java:390)
    	at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:374)
    	at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:655)
    	at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1400)
    	at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1312)
    	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1115)
    	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1209)
    	at net.minecraft.client.Minecraft.run(Minecraft.java:442)
    	at net.minecraft.client.main.Main.main(Main.java:118)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    	at GradleStart.main(GradleStart.java:25)
    
    


  • Pour ta class RenderDyna, essaye de mettre ce code :
    (En remplaçant RenderItemThrowable par RenderDyna)

    @SideOnly(Side.CLIENT)
    public class RenderItemThrowable<T extends Entity> extends Render<T> {
    
        protected final Item item;
        private final RenderItem itemRenderer;
    
        public RenderItemThrowable(RenderManager renderManagerIn, Item itemIn, RenderItem itemRendererIn) {
            super(renderManagerIn);
            this.item = itemIn;
            this.itemRenderer = itemRendererIn;
        }
        public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks) {
            GlStateManager.pushMatrix();
            GlStateManager.translate((float)x, (float)y, (float)z);
            GlStateManager.enableRescaleNormal();
            GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
            GlStateManager.rotate((float)(this.renderManager.options.thirdPersonView == 2 ? -1 : 1) * this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
            GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
            this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    
            if (this.renderOutlines)
            {
                GlStateManager.enableColorMaterial();
                GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            }
    
            this.itemRenderer.renderItem(this.getStackToRender(entity), ItemCameraTransforms.TransformType.GROUND);
    
            if (this.renderOutlines)
            {
                GlStateManager.disableOutlineMode();
                GlStateManager.disableColorMaterial();
            }
    
            GlStateManager.disableRescaleNormal();
            GlStateManager.popMatrix();
            super.doRender(entity, x, y, z, entityYaw, partialTicks);
        }
    
        public ItemStack getStackToRender(T entityIn)
        {
            return new ItemStack(this.item);
        }
    
        @Nullable
        protected ResourceLocation getEntityTexture(Entity entity) {
            return TextureMap.LOCATION_BLOCKS_TEXTURE;
        }
    }
    

    Et au passage, si tu peut envoyer la class ou tu a engregistrer l'entity de ta dynamite.



  • @Asonyx Merci mais toujour le mm bug...

    Voici la classe ou j'enregistre mes Entités.

    public class EntityInit
    {
        public static void registerEntities()
        {
            registerEntity("dyna", EntityDyna.class, Reference.ENTITY_DYNA, 50, 11437146, 000000);
        }
        
        private static void registerEntity(String name, Class<? extends Entity> entity, int id, int range, int color1, int color2)
        {
            EntityRegistry.registerModEntity(new ResourceLocation(Reference.MODID + ":" + name), entity, name, id, Main.instance, range, 1, true, color1, color2);
        }
    }
    


  • Juste, est-ce que c'est toujour le même crash ?



  • @Asonyx oui (je crois)
    au cas ou :

    java.lang.NullPointerException: Rendering entity in world
    	at com.avonia.mod.renderer.entity.RenderDyna.doRender(RenderDyna.java:47)
    	at net.minecraft.client.renderer.entity.RenderManager.renderEntity(RenderManager.java:390)
    	at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:374)
    	at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:655)
    	at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1400)
    	at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1312)
    	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1115)
    	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1209)
    	at net.minecraft.client.Minecraft.run(Minecraft.java:442)
    	at net.minecraft.client.main.Main.main(Main.java:118)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    	at GradleStart.main(GradleStart.java:25)
    


  • Essaye de remplacer dans la class RenderDyna la fonction getEntityTexure par ça :

        @Nullable
        protected ResourceLocation getEntityTexture(Entity entity) throws NullPointerException {
            return TextureMap.LOCATION_BLOCKS_TEXTURE;
        }
    


  • @Asonyx a dit dans RenderItem :

                                                                                                                                    @Nullable                                                                                                                                                                                protected ResourceLocation getEntityTexture(Entity entity) throws NullPointerException {                                                                                                                                                                                    return TextureMap.LOCATION_BLOCKS_TEXTURE;                                                                                                                                                                                }
    

    Nop, 😕

    Cr :

    java.lang.NullPointerException: Rendering entity in world
    	at com.avonia.mod.renderer.entity.RenderDyna.doRender(RenderDyna.java:47)
    	at net.minecraft.client.renderer.entity.RenderManager.renderEntity(RenderManager.java:390)
    	at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:374)
    	at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:655)
    	at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1400)
    	at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1312)
    	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1115)
    	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1209)
    	at net.minecraft.client.Minecraft.run(Minecraft.java:442)
    	at net.minecraft.client.main.Main.main(Main.java:118)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    	at GradleStart.main(GradleStart.java:25)
    


  • Tu peux m'envoyer ta class principale ?



  • @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;
                }
            }
        }
    }
    


  • Tu m'a envoyer la class RegistryEvent...
    Alors que ta class c'est RegisterHandler



  • @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()
        {
    
        }
    }
    


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



  • @Asonyx ah ok



  • @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();
            }
        }
    


  • 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



  • @Asonyx yas inGround et onGround mais aucun ne va.



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


Log in to reply