Register Entity 2



  • Bon pour commencer deso de recommencer un topic deja fait mais je suis obligé
    Bon pour register un entity j'ai cherché un code et je l'ai corrigé mais
    ... CRASH!!!

    Le rapport(EDIT:Je sais pas pourquoi mis il trouve pas le constructeur)

    
    Time: 5/17/19 6:10 PM
    Description: There was a severe problem during mod loading that has caused the game to fail
    
    net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Mod SAO2 created by Daich_'s (sao2)
    Caused by: net.minecraftforge.fml.relauncher.ReflectionHelper$UnknownConstructorException: Could not find constructor 'EntityBallDeser(net.minecraft.world.World)' in class com.daichmff.SAOII.items.gunsweapons.EntityBallDeser
    	at net.minecraftforge.fml.relauncher.ReflectionHelper.findConstructor(ReflectionHelper.java:271)
    	at net.minecraftforge.fml.common.registry.EntityEntryBuilder$ConstructorFactory.<init>(EntityEntryBuilder.java:298)
    	at net.minecraftforge.fml.common.registry.EntityRegistry$EntityRegistration$1.<init>(EntityRegistry.java:81)
    	at net.minecraftforge.fml.common.registry.EntityRegistry$EntityRegistration.<init>(EntityRegistry.java:80)
    	at net.minecraftforge.fml.common.registry.EntityRegistry$EntityRegistration.<init>(EntityRegistry.java:67)
    	at net.minecraftforge.fml.common.registry.EntityRegistry.doModEntityRegistration(EntityRegistry.java:199)
    	at net.minecraftforge.fml.common.registry.EntityRegistry.registerModEntity(EntityRegistry.java:173)
    	at com.daichmff.SAOII.ModSwordArtOnlineII.init(ModSwordArtOnlineII.java:82)
    	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.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:626)
    	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.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218)
    	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196)
    	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.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135)
    	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:744)
    	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336)
    	at net.minecraft.client.Minecraft.init(Minecraft.java:581)
    	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
    	at net.minecraft.client.main.Main.main(Main.java:118)
    	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 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.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    	at GradleStart.main(GradleStart.java:25)
    
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- System Details --
    Details:
    	Minecraft Version: 1.12.2
    	Operating System: Windows 10 (amd64) version 10.0
    	Java Version: 1.8.0_201, Oracle Corporation
    	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    	Memory: 896736168 bytes (855 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)
    	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    	FML: MCP 9.42 Powered by Forge 14.23.5.2768 5 mods loaded, 5 mods active
    	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
    
    	| State | ID        | Version      | Source                           | Signature |
    	|:----- |:--------- |:------------ |:-------------------------------- |:--------- |
    	| UCHI  | minecraft | 1.12.2       | minecraft.jar                    | None      |
    	| UCHI  | mcp       | 9.42         | minecraft.jar                    | None      |
    	| UCHI  | FML       | 8.0.99.99    | forgeSrc-1.12.2-14.23.5.2768.jar | None      |
    	| UCHI  | forge     | 14.23.5.2768 | forgeSrc-1.12.2-14.23.5.2768.jar | None      |
    	| UCHEE | sao2      | 0.1          | bin                              | None      |
    
    	Loaded coremods (and transformers): 
    	GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13467 Compatibility Profile Context 21.19.414.1280' Renderer: 'AMD Radeon(TM) R4 Graphics'
    [18:10:24] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\hyde etienne aaron\Desktop\forge-1.12.2PROJETsao2\run\.\crash-reports\crash-2019-05-17_18.10.15-client.txt
    AL lib: (EE) alc_cleanup: 1 device not closed
    Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
    
    

    La classe de l'entity

    package com.daichmff.SAOII.items.gunsweapons;
    
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.projectile.EntityThrowable;
    import net.minecraft.util.math.RayTraceResult;
    import net.minecraft.world.World;
    
    public class EntityBallDeser extends EntityThrowable {
    
        private double damage;
        int fuseTime = 10000;
    
    	public EntityBallDeser(World worldIn, EntityPlayer player) {
    		super(worldIn);
    	      this.damage = 10.0D;
    	        this.setSize(0.5F, 0.5F);
    	      
    		// TODO Auto-generated constructor stub
    	}
    
    	@Override
    	protected void onImpact(RayTraceResult result) {
    		// TODO Auto-generated method stub
    	    this.motionX = 0;
    	    this.motionY = 0;
    	    this.motionZ = 0;
    
    		
    	}
    	@Override
    	public void onUpdate()
    	{
    	   super.onUpdate();
    	   if(fuseTime > 0){  //si fuseTime est supérieur à 0 alors
    	       this.fuseTime --; // retire 1 a la variable fuseTime
    	   }
    	   else if(!this.world.isRemote) {
    		   this.setDead();
    	   }
    	}
    }
    
    

    La classe principale

    package com.daichmff.SAOII;
    
    import java.awt.Color;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    
    import org.apache.logging.log4j.Logger;
    
    import com.daichmff.SAOII.items.armor.ArmorPro;
    import com.daichmff.SAOII.items.gunsweapons.DesertiGun;
    import com.daichmff.SAOII.items.gunsweapons.EntityBallDeser;
    import com.daichmff.SAOII.items.gunsweapons.SwordLaser;
    
    import net.minecraft.client.renderer.block.model.ModelResourceLocation;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.init.SoundEvents;
    import net.minecraft.inventory.EntityEquipmentSlot;
    import net.minecraft.item.Item;
    import net.minecraft.item.Item.ToolMaterial;
    import net.minecraft.item.ItemArmor.ArmorMaterial;
    import net.minecraft.util.ResourceLocation;
    import net.minecraftforge.client.model.ModelLoader;
    import net.minecraftforge.common.util.EnumHelper;
    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.event.FMLServerStartingEvent;
    import net.minecraftforge.fml.common.registry.EntityRegistry;
    import net.minecraftforge.fml.common.registry.ForgeRegistries;
    
    @Mod(modid = ModSwordArtOnlineII.MODID, name = "Mod SAO2 created by Daich_'s", version = "0.1", acceptedMinecraftVersions = "[1.12.2]")
    public class ModSwordArtOnlineII {
    	 JFrame frame = new JFrame("Salut");
    	 JButton button = new JButton("EXIT");
    	  public static final String MODID = "sao2";
    	  @Instance(ModSwordArtOnlineII.MODID)
    	   public static ModSwordArtOnlineII instance;
    	    @SidedProxy(clientSide = "com.daichmff.SAOII.DaichSaoIIClient", serverSide = "com.daichmff.SAOII.DaichSaoIICommon")
    	    public static DaichSaoIICommon proxy;
    
    	  public static Logger logger;
    	  
    	  public static Item laserSword;
    	  public static Item desertiGun;
    	  public static Item helmetProcetion,chestPlateProcetion,leggingsProcetion,bootsProcetion;
    	  
    	  
    	  
    	  public static ToolMaterial swordLaser = EnumHelper.addToolMaterial("swordLaser", 0, 854, 10.6F, 9.0F, 18);
    	  public static ArmorMaterial armorTuto = EnumHelper.addArmorMaterial("armorTuto", "sao2:iTex", 25, new int[] {2, 2, 2, 2}, 20, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.5F);
    	    @EventHandler
    	    public void preInit(FMLPreInitializationEvent event)
    	    {
    	      
    	    	logger = event.getModLog();//Init DU logger avec le modid
    	    	 proxy.preInit(event.getSuggestedConfigurationFile());
    	    	
    	    }
    	    @EventHandler
    	    public void init(FMLInitializationEvent event)
    	    {
    	    	 proxy.init();
    	    	
    	    	 frame.setVisible(true);
    	    	 frame.setSize(840, 840/16*9);
    	    	 
    	    	 frame.setContentPane(button);
    	    	 laserSword = new SwordLaser(swordLaser).setUnlocalizedName("tutoriel").setCreativeTab(CreativeTabs.COMBAT).setRegistryName("swordl");
    	    	 desertiGun = new DesertiGun().setUnlocalizedName("1g").setCreativeTab(CreativeTabs.COMBAT).setRegistryName("gun1");
    	    	 helmetProcetion = new ArmorPro(armorTuto,0, EntityEquipmentSlot.HEAD).setUnlocalizedName("1").setCreativeTab(CreativeTabs.COMBAT).setRegistryName("helmetpro");
    	    	 chestPlateProcetion = new ArmorPro(armorTuto,1, EntityEquipmentSlot.CHEST).setUnlocalizedName("2").setCreativeTab(CreativeTabs.COMBAT).setRegistryName("chestppro");
    	    	leggingsProcetion = new ArmorPro(armorTuto,2, EntityEquipmentSlot.LEGS).setUnlocalizedName("3").setCreativeTab(CreativeTabs.COMBAT).setRegistryName("leggpro");
    	    	bootsProcetion = new ArmorPro(armorTuto,3, EntityEquipmentSlot.FEET).setUnlocalizedName("4").setCreativeTab(CreativeTabs.COMBAT).setRegistryName("bootspro");
    	    	 
    	    	
    	         
    	           EntityRegistry.registerModEntity(new ResourceLocation(this.MODID, "entitydynamite"),EntityBallDeser.class, "entitydynamite", 1, this.instance, 64, 1, true);
    	           
    	  
    	     
    
    
    
    	    	ModSwordArtOnlineII.registerItems(laserSword);
    	    	ModSwordArtOnlineII.registerItems(desertiGun);
    	    	ModSwordArtOnlineII.registerItems(helmetProcetion);
    	    	ModSwordArtOnlineII.registerItems(chestPlateProcetion);
    	    	ModSwordArtOnlineII.registerItems(leggingsProcetion);
    	    	ModSwordArtOnlineII.registerItems(bootsProcetion);
    	    	
    	    	 }
    	    public static void setItemName(Item item, String name)
    	    {
    	        // ici on va attribuer un nom à nos objets
    	        item.setRegistryName(ModSwordArtOnlineII.MODID, name).setUnlocalizedName(ModSwordArtOnlineII.MODID + "." + name);
    	    }
    	    private static void registerItems(Item item) {
    	    	
    	    	
    			// TODO Auto-generated method stub
    	    	ForgeRegistries.ITEMS.register(item);
    	    	ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    	    }                                                                                                                               
     		@EventHandler
    	    public void postInit(FMLPostInitializationEvent event)
    	    {
    	 
    	    }
    	    @EventHandler
    	    public void onServerStart(FMLServerStartingEvent event)
    	    {
    	 
    	    }
    }
    
    

    Merci!


  • Moddeurs confirmés Rédacteurs Administrateurs

    Salut,

    Les entités doivent tous avoir un constructeur avec l'argument world.
    Donc en plus de public EntityBallDeser(World worldIn, EntityPlayer player) ajoute ce constructeur au dessus :

         public EntityBallDeser(World worldIn) {
    		super(worldIn);
    	        this.damage = 10.0D;
                   this.setSize(0.5F, 0.5F);
         }
    

  • Moddeurs confirmés Rédacteurs Administrateurs

    Salut,

    Les entités doivent tous avoir un constructeur avec l'argument world.
    Donc en plus de public EntityBallDeser(World worldIn, EntityPlayer player) ajoute ce constructeur au dessus :

         public EntityBallDeser(World worldIn) {
    		super(worldIn);
    	        this.damage = 10.0D;
                   this.setSize(0.5F, 0.5F);
         }
    

Log in to reply