Résolu Création de bloc
-
Bonjour encore moi, je refais un post car je ne retrouve pas l’ancien.
Alors déjà pour commencer j’ai repris les cours de java sur openclassrooms, et j’ai aussi revu entièrement la manière d’organiser mon mod, avant c’était des organisations que j’avais copier/coller mais là j’ai enfin passé le cap et fais la mienne, qui me semble plus compréhensible et mieux adaptée à mon grand nombre de bloc à ajouter (au moins 500).Seulement un soucis j’ai une erreur “BlockGeneric cannot be resolved to a type” dans ma classe BlockMinefus
Voici mes classes:
La Classe Principale:
package com.degraduck.modminefus; import org.apache.logging.log4j.Logger; import com.degraduck.modminefus.init.BlockMinefus; import com.degraduck.modminefus.proxy.CommonProxy; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; 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.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION) public class ModMinefus { @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) public static CommonProxy proxy; @Instance(Reference.MOD_ID) public static ModMinefus instance; public static Logger logger; @EventHandler public void preInit(FMLPreInitializationEvent event) { proxy.init(); logger = event.getModLog(); BlockMinefus.init(); BlockMinefus.register(); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenders(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
Mon CommonProxy:
package com.degraduck.modminefus.proxy; import java.io.File; import net.minecraft.block.Block; import net.minecraft.item.Item; public class CommonProxy { public void registerRenders() { } public void preInit(File configFile) { //System.out.println("pre init côté commun"); } public void init() { } protected void registerItemTexture(Item item, int metadata, String name){} protected void registerItemTexture(Item item, String name){} protected void registerBlockTexture(Block block, int metadata, String name){} protected void registerBlockTexture(Block block, String name){} }
Mon ClientProxy:
package com.degraduck.modminefus.proxy; import java.io.File; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemModelMesher; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.item.Item; public class ClientProxy extends CommonProxy { public void preInit(File configFile) { //System.out.println("pre init côté client"); } public void registerRenders() { } @Override public void registerItemTexture(Item item, int metadata, String name) { ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher(); mesher.register(item, metadata, new ModelResourceLocation("ModMinefus:" + name, "inventory")); } @Override public void registerItemTexture(Item item, String name) { registerItemTexture(item, 0, name); } @Override public void registerBlockTexture(Block block, int metadata, String name) { registerItemTexture(Item.getItemFromBlock(block), metadata, name); } @Override public void registerBlockTexture(Block block, String name) { registerBlockTexture(block, 0, name); } }
La Classe BlockMinefus en question:
package com.degraduck.modminefus.init; import com.degraduck.modminefus.Reference; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; public class BlockMinefus { public static Block m_grass; public static void init() { /**Block*/ m_grass = new BlockGeneric(Material.rock).setUnlocalizedName("m_grass"); } public static void register() { GameRegistry.registerBlock(m_grass, "m_grass"); } }
Et ma Classe BlockGeneric:
package com.degraduck.modminefus.block; import net.minecraft.block.Block; import net.minecraft.block.material.Material; public class BlockGeneric extends Block { public BlockGeneric(Material materialIn) { super(materialIn); this.setBlockUnbreakable(); this.setResistance(600000); }
Voilà première fois que je part vraiment de rien pour créer mon mod j’espère qu’il n’y à pas trop d’erreurs.
-
Salut,
@‘Degraduck’:je refais un post car je ne retrouve pas l’ancien.
Tu ne le retrouve pas car tu l’as supprimé …
@‘Degraduck’:Seulement un soucis j’ai une erreur “BlockGeneric cannot be resolved to a type” dans ma classe BlockMinefus
Vas dans ta classe BlockMinefus puis appuies sur ctrl + shift + o
-
Hum je voulais modifier j’ai du supprimer ^^
Déjà fais et rien ne change, j’ai même supprimer tous les import et refait et toujours le même soucisEDIT: Problème résolu je me suis trompé dans un des imports
Maintenant comme dis dans mon précédent post, mon bloc à sa texture quand je le pose mais pas quand il est dans ma main.
-
Dans la fonction registerRenders de ton client proxy ajoute :
registerBlockTexture(BlockMinefus.m_grass, “m_grass”); -
Cela ne change rien j’ai la texture du bloc une fois posé, mais toujours pas la texture du bloc sous sa forme d’item dans la main et dans l’inventaire
-
Tu en est où ? Tu as bien 1 fichier JSON dans assets/modid/blockstates, 1 dans assets/modid/models/block et 1 dans assets/modid/models/item ?
-
Oui celui de blockstates:
:::
{
“variants”: {
“normal”: {
“model”: “modminefus:m_grass”
}
}
}
:::celui dans Models/block:
:::
{
“parent”: “block/cube_bottom_top”,
“textures”: {
“bottom”: “modminefus:blocks/m_grass_bottom”,
“top”: “modminefus:blocks/m_grass_top”,
“side”: “modminefus:blocks/m_grass_side”
}
}
:::Et celui dans Models/item:
:::
{
“parent”: “modminefus:block/m_grass”,
“display”: {
“thirdperson”: {
“rotation”: [ 10, -45, 170 ],
“translation”: [ 0, 1.5, -2.75 ],
“scale”: [ 0.375, 0.375, 0.375 ]
}
}
}
::: -
Tes JSONs semblent bon, où as-tu mis registerBlockTexture ? Essai de mettre ton modid en minuscule dans ta fonction registerItemTexture :
mesher.register(item, metadata, new ModelResourceLocation("modminefus:" + name, "inventory"));
-
Le modid en minuscule ne change rien.
J’ai mis registerBlockTexture(BlockMinefus.m_grass, “m_grass”); dans public void registerRenders(){}
Comme indiqué par Robin et toujours pas de changement ^^ -
As-tu des erreurs dans tes logs ?
-
Non pas d’erreurs dans les logs
-
Bonjour, ta fonction registerBlockTexture pour ton bloc n’est tout simplement pas appelée.
-
J’allais effectivement proposer de vérifier cela, car il tout est bon. Tu dis que registerBlockTexture est appelé dans registerRenders mais cette dernière est-elle bien appelée ?
-
Alors j’ai appelé la fonction mais maintenant j’ai un crashreport:
package com.degraduck.modminefus; import org.apache.logging.log4j.Logger; import com.degraduck.modminefus.init.BlockMinefus; import com.degraduck.modminefus.proxy.CommonProxy; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; 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.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION) public class ModMinefus { @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) public static CommonProxy proxy; @Instance(Reference.MOD_ID) public static ModMinefus instance; public static final String MODID = "modminefus"; public static Logger logger; public static CreativeTabs tabMBlock = new CreativeTabs("tabMBlock") { @SideOnly(Side.CLIENT) public Item getTabIconItem() { return Items.gold_ingot; } }; @EventHandler public void preInit(FMLPreInitializationEvent event) { logger = event.getModLog(); proxy.init(); proxy.registerRenders(); BlockMinefus.init(); BlockMinefus.register(); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenders(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
Le crashreport:
:::
–-- Minecraft Crash Report ----
// You should try our sister game, Minceraft!Time: 15/08/16 23:08
Description: Initializing gamejava.lang.NullPointerException: Initializing game
at com.degraduck.modminefus.proxy.ClientProxy.registerItemTexture(ClientProxy.java:32)
at com.degraduck.modminefus.proxy.ClientProxy.registerBlockTexture(ClientProxy.java:45)
at com.degraduck.modminefus.proxy.ClientProxy.registerBlockTexture(ClientProxy.java:51)
at com.degraduck.modminefus.proxy.ClientProxy.registerRenders(ClientProxy.java:23)
at com.degraduck.modminefus.ModMinefus.preInit(ModMinefus.java:51)
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:560)
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 net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189)
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 net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:556)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:455)
at net.minecraft.client.Minecraft.run(Minecraft.java:364)
at net.minecraft.client.main.Main.main(Main.java:116)
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:26)A detailed walkthrough of the error, its code path and all known details is as follows:
– Head –
Stacktrace:
at com.degraduck.modminefus.proxy.ClientProxy.registerItemTexture(ClientProxy.java:32)
at com.degraduck.modminefus.proxy.ClientProxy.registerBlockTexture(ClientProxy.java:45)
at com.degraduck.modminefus.proxy.ClientProxy.registerBlockTexture(ClientProxy.java:51)
at com.degraduck.modminefus.proxy.ClientProxy.registerRenders(ClientProxy.java:23)
at com.degraduck.modminefus.ModMinefus.preInit(ModMinefus.java:51)
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:560)
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 net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189)
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 net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:556)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:455)– Initialization –
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:364)
at net.minecraft.client.main.Main.main(Main.java:116)
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:26)– System Details –
Details:
Minecraft Version: 1.8.9
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_101, Oracle Corporation
Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 669643256 bytes (638 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP 9.19 Powered by Forge 11.15.1.1722 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
UCH mcp{9.19} [Minecraft Coder Pack] (minecraft.jar)
UCH FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8.9-11.15.1.1722.jar)
UCH Forge{11.15.1.1722} [Minecraft Forge] (forgeSrc-1.8.9-11.15.1.1722.jar)
UCE modminefus{1.0.0} [Mod Minefus] (bin)
Loaded coremods (and transformers):
GL info: ’ Vendor: ‘Intel’ Version: ‘4.0.0 - Build 10.18.10.4276’ Renderer: ‘Intel HD Graphics 4000’
Launched Version: 1.8.9
LWJGL: 2.9.4
OpenGL: Intel HD Graphics 4000 GL version 4.0.0 - Build 10.18.10.4276, Intel
GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.Using VBOs: No
Is Modded: Definitely; Client brand changed to ‘fml,forge’
Type: Client (map_client.txt)
Resource Packs:
Current Language: English (US)
Profiler Position: N/A (disabled)
CPU: 4x Intel Core i3-3110M CPU @ 2.40GHz
::: -
Le problème vient de la ligne 32 de ton client proxy (at com.degraduck.modminefus.proxy.ClientProxy.registerItemTexture(ClientProxy.java:32), fais un print des différentes variables de ta fonction pour voir ce qui est null.
-
Résolu merci a tous