[1.7.10] - Entité invisible



  • Bonjour, quand je clicke sur ma dynamite la dynamite se lance, fait le bruit mais l'entité de la dynamite. J'aimerais bien savoir pourquoi. Si vous avez des idée je suis preneur ^^

    La classe principal:

    package net.funfight.funmod;
    
    import cpw.mods.fml.client.registry.RenderingRegistry;
    import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.Mod.EventHandler;
    import cpw.mods.fml.common.SidedProxy;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.event.FMLPostInitializationEvent;
    import cpw.mods.fml.common.event.FMLPreInitializationEvent;
    import net.funfight.funmod.entities.EntityDynamite;
    import net.funfight.funmod.init.InitItems;
    import net.funfight.funmod.proxy.CommonProxy;
    import net.minecraft.client.renderer.entity.RenderSnowball;
    
    @Mod(modid = Funmod.MODID, name = Funmod.NAME, version = Funmod.VERSION)
    public class Funmod 
    {
    	public static final String MODID = "funmod";
    	public static final String NAME = "FunFight";
    	public static final String VERSION = "1.0";
    	
    	public static final String ClientProxy = "net.funfight.funmod.proxy.ClientProxy";
    	public static final String ServerProxy= "net.funfight.funmod.proxy.CommonProxy";
    	
    	@Mod.Instance(MODID)
    	public static Funmod instance;	
    	
    
    
    	@EventHandler
    	public void preInit(FMLPreInitializationEvent e)
    	{
    		InitItems.initItems();
    		InitItems.registerItems();
    	}
    	
    	@EventHandler
    	public void init(FMLInitializationEvent e)
    	{
    		proxy.Register();
    	}
    	
    	@EventHandler
    	public void postInit(FMLPostInitializationEvent e)
    	{
    		
    	}
    	
    	@SidedProxy(clientSide = Funmod.ClientProxy, serverSide = Funmod.ServerProxy) 
    	public static CommonProxy proxy;
    
    	
    
    }
    

    Le ClientProxy:

    package net.funfight.funmod.proxy;
    
    import cpw.mods.fml.client.registry.RenderingRegistry;
    import cpw.mods.fml.common.registry.EntityRegistry;
    import net.funfight.funmod.Funmod;
    import net.funfight.funmod.entities.EntityDynamite;
    import net.funfight.funmod.init.InitItems;
    import net.minecraft.client.renderer.entity.RenderSnowball;
    
    public class ClientProxy extends CommonProxy
    {
    	    @Override
    		public void Register()
    		{
    	    	RenderingRegistry.registerEntityRenderingHandler(EntityDynamite.class, new RenderSnowball(InitItems.dynamite));
    	    	EntityRegistry.registerModEntity(EntityDynamite.class, "EntityDynamite", 420, Funmod.instance, 0, 64, true);
    		}
    
    	}
    
    

    le CommonProxy:

    package net.funfight.funmod.proxy;
    
    import cpw.mods.fml.client.registry.RenderingRegistry;
    import net.funfight.funmod.entities.EntityDynamite;
    import net.funfight.funmod.init.InitItems;
    import net.minecraft.client.renderer.entity.RenderSnowball;
    
    public class CommonProxy 
    {
    	
    	
    	public void Register()
    	{
    		
    	}
    
    }
    

    L'item de la dynamite:

    package net.funfight.funmod.items;
    
    import java.util.Random;
    
    import net.funfight.funmod.Funmod;
    import net.funfight.funmod.entities.EntityDynamite;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.ItemStack;
    import net.minecraft.world.World;
    import net.minecraft.item.Item;
    
    public class ItemDynamite extends Item
    {
    	private String name;
    	
    	public ItemDynamite(String name) 
    	{
    		this.name = name;
    		this.setCreativeTab(CreativeTabs.tabCombat);
    		this.setUnlocalizedName(name);
    		this.setMaxStackSize(16);
    		this.setTextureName(Funmod.MODID + ":" + name);
    		this.setFull3D();
    	}
    	
    	
    	public ItemStack onItemRightClick(ItemStack stack ,World world, EntityPlayer player){
    		
    		
    		Random itemRand = new Random();
    		world.playSoundAtEntity(player, "game.tnt.primed", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    	    if(!world.isRemote){
    	        world.spawnEntityInWorld(new EntityDynamite(world, player)); 
    	        stack.stackSize--;
    	    }
    	    return stack;
    	}
    
    }
    

    et l'entité:

    package net.funfight.funmod.entities;
    
    import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
    import io.netty.buffer.ByteBuf;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.projectile.EntityThrowable;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.util.MovingObjectPosition;
    import net.minecraft.world.World;
    
    public class EntityDynamite extends EntityThrowable implements IEntityAdditionalSpawnData{
        
        private int fuseTime = 50;
    
       
       public EntityDynamite(World world)
       {
           super(world);
       }
    
       public EntityDynamite(World world, EntityLivingBase trowable)
       {
           super(world, trowable);
       }
    
       public EntityDynamite(World world, double double0, double double1, double double2)
       {
           super(world, double0, double1, double2);
       }
       
       protected void onImpact(MovingObjectPosition mop){
    	    this.motionX = 0;
    	    this.motionY = 0;
    	    this.motionZ = 0;
    	
       
    
       
    
       }
       
       @Override
       public void onUpdate()
       {
          super.onUpdate();
          if(fuseTime > 0){  
              this.fuseTime --;
          }
          else if(!this.worldObj.isRemote){ 
              this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 3.0F, false, true);  
              this.setDead();
          }
       
       }
       
       @Override
       public void writeSpawnData(ByteBuf buffer) {
           buffer.writeInt(this.fuseTime);
           buffer.writeDouble(this.motionX);
           buffer.writeDouble(this.motionY);
           buffer.writeDouble(this.motionZ);
       }
       @Override
       public void readSpawnData(ByteBuf additionalData) {
               this.fuseTime = additionalData.readInt();
       			
               this.motionX = additionalData.readDouble();
       	this.motionY = additionalData.readDouble();
       	this.motionZ = additionalData.readDouble();
       }
    
    }
    

  • Administrateurs

    Pas étonnant que ton entité soit invisible, il faut l'enregistrer avant de faire le rendu et pas l'inverse.



  • Mais comment je fait du coup ?



  • Faut que j'echange ces 2 lignes ?:

    	    @Override
    		public void Register()
     		{
    	    	RenderingRegistry.registerEntityRenderingHandler(EntityDynamite.class, new RenderSnowball(InitItems.dynamite));
    	    	EntityRegistry.registerModEntity(EntityDynamite.class, "EntityDynamite", 420, Funmod.instance, 0, 64, true);
    		}
    


  • J'ai echanger les 2 lignes mais toujours pas d'entité 😞



  • @Askipie mais faut pas register l'entité dans le client proxy ... et respecte les conventions java et forge



  • Non c'est bon c'est regler


Log in to reply