Résolu Enregistrer un block de culture (donc sans item block)
-
Bonjour je suis actuellment entrain d’update mon mod pour la 1.12 et pour certains blocs (comme les blocs de culture, les gâteaux) j’ai besoin d’enregistrer uniquement mon block sans son item block et je ne sais pas trop comment m’y prendre.
Je met ici mes fonctions que j’utilise actuellementpublic static void registerBlock(Block block){ ForgeRegistries.BLOCKS.register(block); ItemBlock item = new ItemBlock(block); item.setRegistryName(block.getRegistryName()); ForgeRegistries.ITEMS.register(item); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); } public static void registerBlock(Block block, ItemBlock itemblock) { ForgeRegistries.BLOCKS.register(block); itemblock.setRegistryName(block.getRegistryName()); ForgeRegistries.ITEMS.register(itemblock); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); }
-
Bonjour Aypristyle, pour enregistrer un bloc sans itemBlock il te suffit de créer une nouvelle fonction qui n’enregistre qu’un bloc ^^ Quelque chose du style:
public static void registerBlock(Block block) { ForgeRegistries.BLOCKS.register(block); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); }
-
BonjourEmotionFox je viens d’essayer ta méthode malheuresment elle ne fonctionne pas mon jeu crash lorsque j’essaye de planter ma graine
–-- Minecraft Crash Report ---- // Would you like a cupcake? Time: 9/30/17 5:07 PM Description: Unexpected error java.lang.NullPointerException: Unexpected error at net.minecraft.item.ItemSeeds.getPlant(ItemSeeds.java:61) at net.minecraft.block.Block.canSustainPlant(Block.java:1869) at net.minecraft.item.ItemSeeds.onItemUse(ItemSeeds.java:34) at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:201) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:493) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1674) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2357) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2123) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1910) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1171) at net.minecraft.client.Minecraft.run(Minecraft.java:436) 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:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at net.minecraft.item.ItemSeeds.getPlant(ItemSeeds.java:61) at net.minecraft.block.Block.canSustainPlant(Block.java:1869) at net.minecraft.item.ItemSeeds.onItemUse(ItemSeeds.java:34) at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:201) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:493) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1674) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2357) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2123) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player737'/425, l='MpServer', x=-122.71, y=68.00, z=245.82]] Chunk stats: MultiplayerChunkCache: 519, 519 Level seed: 0 Level generator: ID 00 - default, ver 1\. Features enabled: false Level generator options: Level spawn location: World: (-120,64,252), Chunk: (at 8,4,12 in -8,15; contains blocks -128,0,240 to -113,255,255), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 11845 game time, 11845 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 102 total; [EntityWolf['Wolf'/264, l='MpServer', x=-99.70, y=75.00, z=226.30], EntityItem['item.tile.cloth.white'/265, l='MpServer', x=-105.94, y=72.00, z=241.88], EntityItem['item.item.muttonRaw'/266, l='MpServer', x=-105.87, y=72.00, z=240.77], EntityItem['item.tile.cloth.white'/267, l='MpServer', x=-106.96, y=73.00, z=245.32], EntityItem['item.item.muttonRaw'/268, l='MpServer', x=-105.41, y=74.00, z=245.85], EntitySkeleton['Skeleton'/273, l='MpServer', x=-90.51, y=19.00, z=179.22], EntityItem['item.tile.cloth.white'/274, l='MpServer', x=-84.64, y=76.00, z=234.29], EntityItem['item.item.muttonRaw'/275, l='MpServer', x=-84.09, y=76.00, z=234.94], EntityCreeper['Creeper'/276, l='MpServer', x=-81.50, y=26.00, z=248.50], EntityItem['item.tile.cloth.white'/277, l='MpServer', x=-87.14, y=75.00, z=248.93], EntityItem['item.item.muttonRaw'/278, l='MpServer', x=-86.90, y=75.00, z=249.36], EntitySkeleton['Skeleton'/279, l='MpServer', x=-87.41, y=27.00, z=261.74], EntitySkeleton['Skeleton'/293, l='MpServer', x=-65.50, y=12.00, z=205.74], EntityZombie['Zombie'/294, l='MpServer', x=-68.50, y=17.00, z=299.50], EntityZombie['Zombie'/316, l='MpServer', x=-60.69, y=11.30, z=185.74], EntityZombie['Zombie'/317, l='MpServer', x=-59.81, y=12.00, z=180.56], EntityZombie['Zombie'/318, l='MpServer', x=-57.30, y=11.75, z=182.30], EntityCreeper['Creeper'/319, l='MpServer', x=-59.50, y=36.00, z=201.19], EntityBat['Bat'/320, l='MpServer', x=-48.34, y=21.10, z=212.68], EntityCreeper['Creeper'/321, l='MpServer', x=-58.03, y=34.00, z=216.58], EntitySkeleton['Skeleton'/322, l='MpServer', x=-61.14, y=41.00, z=234.44], EntityLlama['Llama'/107, l='MpServer', x=-194.51, y=99.00, z=187.63], EntitySkeleton['Skeleton'/110, l='MpServer', x=-195.50, y=70.00, z=240.67], EntityLlama['Llama'/112, l='MpServer', x=-201.48, y=81.00, z=264.44], EntitySpider['Spider'/123, l='MpServer', x=-178.04, y=64.00, z=166.04], EntitySpider['Spider'/124, l='MpServer', x=-185.09, y=63.00, z=176.40], EntityEnderman['Enderman'/125, l='MpServer', x=-181.56, y=40.00, z=206.48], EntityZombie['Zombie'/126, l='MpServer', x=-183.51, y=66.00, z=194.29], EntityBat['Bat'/127, l='MpServer', x=-184.40, y=37.04, z=217.17], EntityZombie['Zombie'/128, l='MpServer', x=-187.53, y=38.00, z=229.20], EntityBat['Bat'/129, l='MpServer', x=-191.54, y=31.10, z=240.25], EntityBat['Bat'/130, l='MpServer', x=-190.05, y=24.10, z=258.23], EntityBat['Bat'/131, l='MpServer', x=-186.25, y=20.10, z=259.45], EntityLlama['Llama'/132, l='MpServer', x=-184.50, y=83.00, z=287.08], EntityChicken['Chicken'/133, l='MpServer', x=-177.85, y=80.00, z=302.57], EntityLlama['Llama'/134, l='MpServer', x=-184.49, y=83.00, z=289.11], EntityChicken['Chicken'/136, l='MpServer', x=-177.81, y=80.00, z=305.38], EntityItem['item.item.egg'/137, l='MpServer', x=-177.37, y=80.00, z=304.51], EntityLlama['Llama'/138, l='MpServer', x=-181.30, y=80.00, z=324.90], EntityBat['Bat'/160, l='MpServer', x=-173.25, y=59.10, z=185.75], EntitySkeleton['Skeleton'/161, l='MpServer', x=-161.50, y=41.00, z=219.14], EntityZombie['Zombie'/162, l='MpServer', x=-161.49, y=42.00, z=214.81], EntityBat['Bat'/163, l='MpServer', x=-163.38, y=41.73, z=223.75], EntityWolf['Wolf'/164, l='MpServer', x=-170.41, y=70.00, z=224.50], EntityWolf['Wolf'/165, l='MpServer', x=-161.44, y=80.00, z=243.28], EntityLlama['Llama'/166, l='MpServer', x=-174.47, y=82.00, z=284.50], EntityItem['item.item.egg'/424, l='MpServer', x=-131.19, y=81.00, z=301.89], EntityPlayerSP['Player737'/425, l='MpServer', x=-122.71, y=68.00, z=245.82], EntityZombie['Zombie'/176, l='MpServer', x=-157.51, y=54.00, z=192.74], EntitySpider['Spider'/177, l='MpServer', x=-159.00, y=56.00, z=190.97], EntityBat['Bat'/178, l='MpServer', x=-138.64, y=42.10, z=218.37], EntityBat['Bat'/179, l='MpServer', x=-149.20, y=42.44, z=219.62], EntityWolf['Wolf'/180, l='MpServer', x=-153.72, y=72.00, z=217.53], EntityWolf['Wolf'/181, l='MpServer', x=-152.53, y=71.00, z=205.74], EntityChicken['Chicken'/182, l='MpServer', x=-159.96, y=71.00, z=214.28], EntityChicken['Chicken'/183, l='MpServer', x=-151.47, y=72.00, z=232.01], EntityWolf['Wolf'/184, l='MpServer', x=-151.48, y=72.00, z=228.27], EntityItem['item.item.egg'/185, l='MpServer', x=-150.21, y=71.00, z=227.69], EntityBat['Bat'/441, l='MpServer', x=-152.09, y=30.10, z=181.99], EntityItem['item.item.egg'/186, l='MpServer', x=-153.33, y=72.00, z=239.34], EntityWolf['Wolf'/187, l='MpServer', x=-156.55, y=73.00, z=223.73], EntityChicken['Chicken'/188, l='MpServer', x=-157.41, y=79.00, z=247.16], EntityItem['item.item.egg'/189, l='MpServer', x=-157.88, y=79.00, z=247.88], EntitySpider['Spider'/190, l='MpServer', x=-148.89, y=13.00, z=263.61], EntityCreeper['Creeper'/191, l='MpServer', x=-144.52, y=13.00, z=270.20], EntityChicken['Chicken'/192, l='MpServer', x=-145.86, y=78.00, z=269.48], EntityItem['item.item.egg'/193, l='MpServer', x=-150.81, y=77.00, z=263.70], EntityCreeper['Creeper'/194, l='MpServer', x=-158.50, y=15.00, z=272.22], EntityZombie['Zombie'/195, l='MpServer', x=-153.51, y=34.00, z=283.19], EntityBat['Bat'/196, l='MpServer', x=-148.63, y=43.10, z=290.98], EntityItem['item.tile.cloth.white'/202, l='MpServer', x=-129.62, y=69.00, z=196.07], EntityItem['item.item.muttonRaw'/203, l='MpServer', x=-128.73, y=69.00, z=196.64], EntityBat['Bat'/204, l='MpServer', x=-140.25, y=15.10, z=269.59], EntityChicken['Chicken'/205, l='MpServer', x=-132.15, y=86.00, z=282.14], EntityChicken['Chicken'/206, l='MpServer', x=-129.82, y=86.00, z=286.50], EntityItem['item.item.egg'/207, l='MpServer', x=-137.89, y=85.00, z=286.86], EntityItem['item.item.egg'/208, l='MpServer', x=-131.67, y=86.00, z=282.27], EntityItem['item.item.egg'/209, l='MpServer', x=-129.93, y=85.00, z=289.68], EntityChicken['Chicken'/210, l='MpServer', x=-131.12, y=81.00, z=302.56], EntityCreeper['Creeper'/231, l='MpServer', x=-120.31, y=16.00, z=168.20], EntityZombie['Zombie'/233, l='MpServer', x=-118.52, y=32.05, z=168.91], EntityBat['Bat'/235, l='MpServer', x=-119.48, y=33.07, z=169.42], EntityCow['Cow'/236, l='MpServer', x=-124.32, y=79.00, z=174.59], EntityCreeper['Creeper'/237, l='MpServer', x=-118.50, y=33.00, z=188.50], EntityItem['item.tile.cloth.white'/238, l='MpServer', x=-125.74, y=69.00, z=204.89], EntityItem['item.item.muttonRaw'/239, l='MpServer', x=-125.19, y=69.00, z=206.07], EntityItem['item.tile.cloth.white'/240, l='MpServer', x=-125.21, y=68.00, z=200.70], EntityItem['item.item.muttonRaw'/241, l='MpServer', x=-125.40, y=69.00, z=199.68], EntityWolf['Wolf'/242, l='MpServer', x=-122.60, y=72.00, z=189.48], EntityItem['item.tile.cloth.white'/243, l='MpServer', x=-121.26, y=69.00, z=197.44], EntityItem['item.item.muttonRaw'/244, l='MpServer', x=-121.13, y=69.00, z=197.61], EntityCow['Cow'/245, l='MpServer', x=-124.53, y=69.00, z=204.19], EntityCow['Cow'/246, l='MpServer', x=-124.85, y=69.00, z=200.06], EntityCow['Cow'/247, l='MpServer', x=-124.47, y=69.00, z=199.09], EntityCreeper['Creeper'/248, l='MpServer', x=-121.80, y=53.00, z=223.46], EntityCreeper['Creeper'/249, l='MpServer', x=-122.84, y=52.00, z=221.49], EntityZombieVillager['Zombie Villager'/250, l='MpServer', x=-126.75, y=21.00, z=249.52], EntityZombie['Zombie'/251, l='MpServer', x=-112.70, y=19.00, z=266.49], EntityZombieVillager['Zombie Villager'/252, l='MpServer', x=-116.30, y=22.00, z=256.55], EntityZombieVillager['Zombie Villager'/253, l='MpServer', x=-117.04, y=22.00, z=256.05], EntityZombie['Zombie'/254, l='MpServer', x=-120.50, y=66.00, z=299.50], EntityChicken['Chicken'/255, l='MpServer', x=-127.49, y=86.00, z=289.83]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:456) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2863) at net.minecraft.client.Minecraft.run(Minecraft.java:465) 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:26) – System Details -- Details: Minecraft Version: 1.12 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_131, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 715089640 bytes (681 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95 FML: MCP 9.40 Powered by Forge 14.21.1.2387 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 UCHIJAAAA minecraft{1.12} [Minecraft] (minecraft.jar) UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.12-14.21.1.2387.jar) UCHIJAAAA forge{14.21.1.2387} [Minecraft Forge] (forgeSrc-1.12-14.21.1.2387.jar) UCHIJAAAA simpleores{1.0 - MC 1.12} [Aypristyle] (bin) Loaded coremods (and transformers): GL info: ' Vendor: 'Intel' Version: '4.4.0 - Build 21.20.16.4475' Renderer: 'Intel(R) HD Graphics 500' Launched Version: 1.12 LWJGL: 2.9.4 OpenGL: Intel(R) HD Graphics 500 GL version 4.4.0 - Build 21.20.16.4475, 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: Yes 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: 2x Intel(R) Celeron(R) CPU N3350 @ 1.10GHz
Ps: J’ai vu que toi aussi tu avais un peu de mal a up ton mod imagine la galère que ça va être avec la 1.13 après
-
Pourquoi s’embêter enregistre le comme un block normal et puis voila et t’aura toujours ton item pour faire pop le block en jeu
-
Euhhh… C’est quoi cette manière d’enregistrer un block ?! o_0
En 1.12, il faut utiliser l’événement RegistryEvent.Register<block>.Et le crash vient du fait que le bloc qui doit apparaître lorsque tu fait clic droit sur ton seed sur de la terre est null. C’est à dire que lorsque tu as fait new ItemSeeds(crops, soil) dans ton code,* l’instance du bloc du *premier argument est null.</block>
-
J’imagine bien aypristyle, heureusement une bonne connaissance en java m’aide pas mal ^^ Comme la dit Alexandre1156 il faudrait maintenant enregistrer les blocs et les items dans une méthode comme celle-là:
@SubscribeEvent public static void registerBlock(RegistryEvent.Register <block>e) { e.getRegistry().registerAll(EmotionBlock.getBlocks()); }
Sans oublier de rajouter en dehors de ta class et en dessous des importations:
@Mod.EventBusSubscriber(modid = tonModID)
Et enfin pour comprendre le problème que signale Alexandre, les blocs s’enregistre après les items ce qui fait qu’au moment où tu le cite il est égale à null; il faut donc trouver un moyen de résoudre ça, personnellement je créer une classe qui extends ItemSeeds pour définir le corps et le soil directement dans la class, mais il y a forcement une meilleure méthode.
P.S: Pour n’avoir vraiment aucun item même l’item du bloc il faudra enlever ça:
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); ```</block>
-
Merci beaucoup à tous vous m’avez bien aider ! Au final j’ai changer l’ordre de mes enregistrement pour mettre mon bloc avant mes items et ça a fonctionné !