
Enderlook
Members-
Posts
45 -
Joined
-
Last visited
Everything posted by Enderlook
-
How to improve my codding style for registry
Enderlook replied to Enderlook's topic in Modder Support
Ok, thanks, I'll perform the update. Ok, I was about to ask that also. Thanks, I'll perform the modifications. -
Asking for help in this forum, some people have told me that I'm using a common wrong coding style that I should avoid: So, I want to ask a few questions: Currently, I have a common, a client and a server (which I don't use) proxy. That topic said everything from common proxy should be moved to the main file. So my question is if I should do something like this: Basically: Move everything from CommonProxy to main file (ExtraCraft). Delete CommonProxy. Change inheritance of ClientProxy from CommonProxy to ExtraCraft. Change inheritance of ServerProxy from CommonProxy to ExtraCraft. CommonProxy: (Delete it) //@Mod.EventBusSubscriber(modid = ExtraCraft.MOD_ID) public class CommonProxy { // Config instance /*public static Configuration config; public void preInitializationEvent(FMLPreInitializationEvent event) { File directory = event.getModConfigurationDirectory(); config = new Configuration(new File(directory.getPath(), "modtut.cfg")); Config.readConfig(); } public void initializationEvent(FMLInitializationEvent event) { } public void postInitializationEvent(FMLPostInitializationEvent event) { if (config.hasChanged()) { config.save(); } } @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { ModItems.registerItems(event); ModBlocks.registerItemBlocks(event); } @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event) { ModBlocks.registerBlocks(event); } public void registerRenderers() { }*/ } ClientProxy: (Change inheritance) @Mod.EventBusSubscriber(modid = ExtraCraft.MOD_ID, value = Side.CLIENT) public class ClientProxy extends ExtraCraft /*CommonProxy*/{ @Override public void preInitializationEvent(FMLPreInitializationEvent event) { super.preInitializationEvent(event); } @Override public void initializationEvent(FMLInitializationEvent event) { super.initializationEvent(event); } @Override public void postInitializationEvent(FMLPostInitializationEvent event) { super.postInitializationEvent(event); } @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { ModItems.initializeItemsModels(); ModBlocks.initializeBlockModels(); } @Override public void registerRenderers() { } } ServerProxy: (Change inheritance) @Mod.EventBusSubscriber(modid = ExtraCraft.MOD_ID, value = Side.SERVER) public class ServerProxy extends ExtraCraft /*CommonProxy*/ { @Override public void preInitializationEvent(FMLPreInitializationEvent event) { super.preInitializationEvent(event); } @Override public void initializationEvent(FMLInitializationEvent event) { super.initializationEvent(event); } @Override public void postInitializationEvent(FMLPostInitializationEvent event) { super.postInitializationEvent(event); } } ExtraCraft: (Get all the code from CommonProxy) @Mod(modid = ExtraCraft.MOD_ID, name = ExtraCraft.NAME, version = ExtraCraft.VERSION) /*ADD*/ @Mod.EventBusSubscriber(modid = ExtraCraft.MOD_ID) public class ExtraCraft { public static final String MOD_ID = "extracraft"; public static final String NAME = "ExtraCraft Mod"; public static final String VERSION = "0.1.0.0"; /*ADD*/ public static Configuration config; static Logger logger; // private @SidedProxy(clientSide = "net.enderlook.extracraft.proxy.ClientProxy", serverSide = "net.enderlook.extracraft.proxy.ServerProxy") //private static CommonProxy proxy; @Mod.Instance private static ExtraCraft instance; @Mod.EventHandler public void preInitializationEvent(FMLPreInitializationEvent event) { logger = event.getModLog(); //proxy.preInitializationEvent(event); /*ADD*/ File directory = event.getModConfigurationDirectory(); /*ADD*/ config = new Configuration(new File(directory.getPath(), "modtut.cfg")); /*ADD*/ Config.readConfig(); ModBlocks.init();; } @Mod.EventHandler public void initializationEvent(FMLInitializationEvent event) { //proxy.initializationEvent(event); ModRecipes.init(); } @Mod.EventHandler public void postInitializationEvent(FMLPostInitializationEvent event) { //proxy.postInitializationEvent(event); /*ADD*/ if (config.hasChanged()) { /*ADD*/ config.save(); /*ADD*/ } } public static String appendModID(String value) { return MOD_ID + ":" + value; } /*ADD*/ @SubscribeEvent /*ADD*/ public static void registerItems(final RegistryEvent.Register<Item> event) { /*ADD*/ ModItems.registerItems(event); /*ADD*/ ModBlocks.registerItemBlocks(event); /*ADD*/ } /*ADD*/ @SubscribeEvent /*ADD*/ public static void registerBlocks(final RegistryEvent.Register<Block> event) { /*ADD*/ ModBlocks.registerBlocks(event); /*ADD*/ } /*ADD*/ public void registerRenderers() { /*ADD*/ /*ADD*/ } } The code in comments will be deleted, code with "/*ADD*/" will be added. Furthermore this critical change, should I do another critical change. Is fine my "registerItems" and "registerBlocks" event or I should try also to move them?. So, should I delete that last 3 methods and just add "@SubscribeEvent" on each one in their classes's methods ("ModItems", "ModBlocks")
-
Why my Block doesn't have graphics? [SOLVED]
Enderlook replied to Enderlook's topic in Modder Support
Oh my god! It works!!!, I can't believe that all my problems were being typos. I'm sorry. THANK YOU VERY MUCH!!! -
Why my Block doesn't have graphics? [SOLVED]
Enderlook replied to Enderlook's topic in Modder Support
I've fixed the typo. New error log : [12:48:31] [main/ERROR] [FML]: Could not load vanilla model parent 'minecraft:blocks/cube_all' for 'net.minecraft.client.renderer.block.model.ModelBlock@649ded12 net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model minecraft:blocks/cube_all with loader VanillaLoader.INSTANCE, skipping at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModelOrLogError(ModelLoaderRegistry.java:203) [ModelLoaderRegistry.class:?] at net.minecraftforge.client.model.ModelLoader$VanillaModelWrapper.getTextures(ModelLoader.java:395) [ModelLoader$VanillaModelWrapper.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:163) [ModelLoaderRegistry.class:?] at net.minecraftforge.client.model.ModelLoader$WeightedRandomModel.<init>(ModelLoader.java:667) [ModelLoader$WeightedRandomModel.class:?] at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1183) [ModelLoader$VariantLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) [ModelLoaderRegistry.class:?] at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:237) [ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:153) [ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:225) [ModelLoader.class:?] at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:152) [ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?] at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?] at net.minecraft.client.Minecraft.init(Minecraft.java:559) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:25) [start/:?] Caused by: java.io.FileNotFoundException: minecraft:models/blocks/cube_all.json at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:69) ~[FallbackResourceManager.class:?] at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:65) ~[SimpleReloadableResourceManager.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.access$1600(ModelLoader.java:117) ~[ModelLoader.class:?] at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:870) ~[ModelLoader$VanillaLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?] ... 27 more Should I rework my registring code right now or can I do that later? I would prefer first fix my 2 blocks and later rework that, I would prefer not to make new problems on the existing ones. Or it's necessary to fix my bug? -
Why my Block doesn't have graphics? [SOLVED]
Enderlook replied to Enderlook's topic in Modder Support
ModBlocks.java @EventBusSubscriber(modid = ExtraCraft.MOD_ID) public class ModBlocks { @ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block") public static final BlockSugar BLOCK_SUGAR = null; @ObjectHolder(ExtraCraft.MOD_ID + ":gunpowder_block") public static final BlockGunpowder BLOCK_GUNPOWDER = null; private static CBlockFalling[] BLOCK_FALLING; public static void init() { BLOCK_FALLING = new CBlockFalling[] { new BlockSugar(), new BlockGunpowder() }; } @SideOnly(Side.CLIENT) public static void initializeBlockModels() { for (IInitModel block : BLOCK_FALLING) { block.initializeModel(); } }; public static void registerBlocks(final RegistryEvent.Register<Block> event) { final IForgeRegistry<Block> registry = event.getRegistry(); registry.registerAll(BLOCK_FALLING); }; public static void registerItemBlocks(final RegistryEvent.Register<Item> event) { for (CBlockFalling block : BLOCK_FALLING) { block.registerItemBlock(event); } } } In my main file ("Extracraftj.java"): @Mod(modid = ExtraCraft.MOD_ID, name = ExtraCraft.NAME, version = ExtraCraft.VERSION) // [...] @Mod.EventHandler public void preInitializationEvent(FMLPreInitializationEvent event) { logger = event.getModLog(); proxy.preInitializationEvent(event); ModBlocks.init(); } // [...] In "CommonProxy.java": @Mod.EventBusSubscriber(modid = ExtraCraft.MOD_ID) // [...] @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { ModItems.registerItems(event); ModBlocks.registerItemBlocks(event); } @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event) { ModBlocks.registerBlocks(event); } // [...] In "ClientProxy.java": @Mod.EventBusSubscriber(modid = ExtraCraft.MOD_ID, value = Side.CLIENT) // [...] @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { ModItems.initializeItemsModels(); ModBlocks.initializeBlockModels(); } // [...] In "assets/extracraft/blockstates/gunpowder_block.json" (I've the same for sugar_block): { "forge_maker": 1, "defaults": { "model": "extracraft:gunpowder_block" }, "variants": { "normal": [{}], "inventory": [{}] } } In "assets/extracraft/blocksates/gunpowder_block.json" (I've the same for sugar_block); { "parent": "blocks/cube_all", "textures": { "all": "extracraft:blocks/gunpowder_block" } } In "assets/extracraft/textures/blocks" I've "gunpowder_block.png" and "sugar_block.png" -
Why my Block doesn't have graphics? [SOLVED]
Enderlook replied to Enderlook's topic in Modder Support
Furthermore the crash report, I've noted that when Minecraft doesn't crash (because I don't use "@SubscribeEvent") I get this error in the log: https://pastebin.com/Pfj7PR6b In line 15 it says: [11:36:00] [main/ERROR] [FML]: Exception loading model for variant extracraft:sugar_block#normal for blockstate "extracraft:sugar_block" net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model extracraft:sugar_block#normal with loader VariantLoader.INSTANCE, skipping And in line 39: Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:83) ~[ModelBlockDefinition.class:?] at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1182) ~[ModelLoader$VariantLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?] But I don't know what means that or how to fix it. -
Why my Block doesn't have graphics? [SOLVED]
Enderlook replied to Enderlook's topic in Modder Support
Adding "@SubscribeEvent" before "registerBlocks" and "registerItemBlocks" produces: ---- Minecraft Crash Report ---- Description: Initializing game java.lang.RuntimeException: One of more entry values did not copy to the correct id. Check log for details! at net.minecraftforge.registries.ForgeRegistry.sync(ForgeRegistry.java:547) at net.minecraftforge.registries.GameData.loadRegistry(GameData.java:494) at net.minecraftforge.registries.GameData.freezeData(GameData.java:229) at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:753) at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:329) 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: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at net.minecraftforge.registries.ForgeRegistry.sync(ForgeRegistry.java:547) at net.minecraftforge.registries.GameData.loadRegistry(GameData.java:494) at net.minecraftforge.registries.GameData.freezeData(GameData.java:229) at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:753) at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:329) at net.minecraft.client.Minecraft.init(Minecraft.java:581) -- Initialization -- Details: Stacktrace: 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) -
Why my Block doesn't have graphics? [SOLVED]
Enderlook replied to Enderlook's topic in Modder Support
So... I should do?: @EventBusSubscriber(modid = ExtraCraft.MOD_ID) public class CBlocks { @ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block") public static final BlockSugar BLOCK_SUGAR = null; @ObjectHolder(ExtraCraft.MOD_ID + ":gunpowder_block") public static final BlockGunpowder BLOCK_GUNPOWDER = null; private static CBlockFalling[] BLOCK_FALLING; public static void init() { BLOCK_FALLING = new CBlockFalling[] { new BlockSugar(), new BlockGunpowder() }; } @SideOnly(Side.CLIENT) public static void initializeBlockModels() { for (IInitModel block : BLOCK_FALLING) { block.initializeModel(); } }; public static void registerBlocks(final RegistryEvent.Register<Block> event) { final IForgeRegistry<Block> registry = event.getRegistry(); registry.registerAll(BLOCK_FALLING); }; public static void registerItemBlocks(final RegistryEvent.Register<Item> event) { for (CBlockFalling block : BLOCK_FALLING) { block.registerItemBlock(event); } } } I don't understand :(, Graphics still doesn't work, and if I add "@SubscribeEvent" it crashes. -
Why my Block doesn't have graphics? [SOLVED]
Enderlook replied to Enderlook's topic in Modder Support
Something like this?: @EventBusSubscriber(modid = ExtraCraft.MOD_ID) public class CBlocks { @ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block") public static final BlockSugar BLOCK_SUGAR = null; @ObjectHolder(ExtraCraft.MOD_ID + ":gunpowder_block") public static final BlockGunpowder BLOCK_GUNPOWDER = null; @SideOnly(Side.CLIENT) public static void initializeBlockModels() { CBlockFalling[] BLOCK_FALLING = new CBlockFalling[] { new BlockSugar(), new BlockGunpowder() }; for (IInitModel block : BLOCK_FALLING) { block.initializeModel(); } }; @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event) { final IForgeRegistry<Block> registry = event.getRegistry(); CBlockFalling[] BLOCK_FALLING = new CBlockFalling[] { new BlockSugar(), new BlockGunpowder() }; registry.registerAll(BLOCK_FALLING); }; @SubscribeEvent public static void registerItemBlocks(final RegistryEvent.Register<Item> event) { CBlockFalling[] BLOCK_FALLING = new CBlockFalling[] { new BlockSugar(), new BlockGunpowder() }; for (CBlockFalling block : BLOCK_FALLING) { block.registerItemBlock(event); } } } When I write "@SubscribeEvent" the game crash: Initializing game java.lang.RuntimeException: One of more entry values did not copy to the correct id. Check log for details! at net.minecraftforge.registries.ForgeRegistry.sync(ForgeRegistry.java:547) at net.minecraftforge.registries.GameData.loadRegistry(GameData.java:494) at net.minecraftforge.registries.GameData.freezeData(GameData.java:229) at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:753) at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:329) 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) Also it crash if I try: Item[] toRegister = new Item[]{ new ItemBlock(BLOCK_SUGAR).setRegistryName("extracraft:sugar_block"), new ItemBlock(BLOCK_GUNPOWDER).setRegistryName("extracraft:gunpowder_block") }; event.getRegistry().registerAll(toRegister); -
Why my Block doesn't have graphics? [SOLVED]
Enderlook replied to Enderlook's topic in Modder Support
Ok, I've tried to adapt that example to my code as I could, but I also have "initializeBlockModels" which I haven't found on the example. In addition to that, I noticed that 2 times the array of the blocks were made (to register block and to register their item shape). Why not use just one array?: @EventBusSubscriber(modid = ExtraCraft.MOD_ID) public class CBlocks { @ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block") public static final BlockSugar BLOCK_SUGAR = null; @ObjectHolder(ExtraCraft.MOD_ID + ":gunpowder_block") public static final BlockGunpowder BLOCK_GUNPOWDER = null; public static CBlockFalling[] BLOCK_FALLING = new CBlockFalling[] { // I've changed from CBlockBasic to CBlockFalling new BlockSugar(), new BlockGunpowder() }; @SideOnly(Side.CLIENT) public static void initializeBlockModels() { for (IInitModel block : BLOCK_FALLING) { block.initializeModel(); } }; public static void registerBlocks(final RegistryEvent.Register<Block> event) { final IForgeRegistry<Block> registry = event.getRegistry(); registry.registerAll(BLOCK_FALLING); }; public static void registerItemBlocks(final RegistryEvent.Register<Item> event) { for (CBlockFalling block : BLOCK_FALLING) { block.registerItemBlock(event); } } } Each block has already this two methods inside: @Override @SideOnly(Side.CLIENT) public void initializeModel() { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "inventory")); }; public void registerItemBlock(final RegistryEvent.Register<Item> event) { event.getRegistry().register(new ItemBlock(this).setRegistryName(getRegistryName())); } Note that sadly graphics still doesn't work -
Why my Block doesn't have graphics? [SOLVED]
Enderlook replied to Enderlook's topic in Modder Support
I'm sorry for my lack of knowledge, but I should do this?: @ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block") public static BlockSugar BLOCK_SUGAR; public static final CBlockBasic[] BLOCKS_BASIC = new CBlockBasic[] { BLOCK_SUGAR }; public static void init() { BLOCK_SUGAR = new BlockSugar("sugar_block"); } In order to do that, I had to remove the "final" of BLOCK_SUGAR, is that okay? By the way, that crashed Minecraft : ---- Minecraft Crash Report ---- // I just don't know what went wrong :( Time: 8/4/18 11:11 AM Description: Initializing game java.lang.NullPointerException: Can't use a null-name for the registry, object null. at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:864) at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:291) at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:285) at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:118) at net.minecraftforge.registries.ForgeRegistry.registerAll(ForgeRegistry.java:159) at net.enderlook.extracraft.blocks.init.CBlocks.registerBlocks(CBlocks.java:53) at net.enderlook.extracraft.proxy.CommonProxy.registerBlocks(CommonProxy.java:56) [...] I'm not sure which is the error because "registry.registerAll" is executed after the init, not before, so it shouldn't be null, right? -
Why my Block doesn't have graphics? [SOLVED]
Enderlook replied to Enderlook's topic in Modder Support
But when the value will be assigned? Would Minecraft do that automatically? Also, if I do that, how later will I be able to register them? I can't make an array with them if they aren't assigned. Also, I couldn't iterate over that array to initialize their models, item version nor I couldn't register them. -
Why my Block doesn't have graphics? [SOLVED]
Enderlook replied to Enderlook's topic in Modder Support
I'm sorry, but I don't understand you. Should I do?: @ObjectHolder(null) public static final BlockSugar BLOCK_SUGAR = new BlockSugar("sugar_block"); That gives an error. And, also I should do this? "normal": [{"model": "extracraft:sugar_block"}], How Minecraft would know that sugar_block is inside models? Also, it still doesn't work the graphic. -
I think I am doing something wrong, but I'm not sure. My block has the black and violet graphic as item and as block. In the folder assets\extracraft\textures\blocks I have sugar_block.png. In the folder assets\extracraft\models\block I have this sugar_block.json: { "parent": "blocks/cube_all", "textures": { "all": "extracraft:blocks/sugar_block" } } In the folder assets\extracraft\blockstates I have this sugar_block.json: { "forge_maker": 1, "defaults": { "model": "extracraft:sugar_block" }, "variants": { "normal": [{"model": "extracraft:models/sugar_block"}], "inventory": [{}] } } And in my code I have: @ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block") public static final BlockSugar BLOCK_SUGAR = new BlockSugar("sugar_block"); *extracraft is my mod id. Why doesn't it work? What am I doing wrong?
-
My constructor is: public CItemToolAxe(String unlocalizedName, CreativeTabs tab, ToolMaterial material) { super(material); this.setRegistryName(unlocalizedName); this.setUnlocalizedName(unlocalizedName); this.setCreativeTab(tab); } And my material is: public static final ToolMaterial FLINT_MATERIAL = EnumHelper.addToolMaterial("Flint", 1, 95, 3f, 0.5f, 7); Your idea is fixing that like: super(material, 3f, 0.5f); Which works. But could I also use this?: super(material, material.getEfficiency(), material.getAttackDamage()); It seems to works also.
-
I'm trying to make a tool but I don't have any idea why this is causing a bug. Could you help me? PMDescription: Initializing game java.lang.ExceptionInInitializerError at net.enderlook.extracraft.proxy.CommonProxy.registerItems(CommonProxy.java:49) [...] Caused by: java.lang.ArrayIndexOutOfBoundsException: 5 at net.minecraft.item.ItemAxe.<init>(ItemAxe.java:19) at net.enderlook.extracraft.items.base.CItemToolAxe.<init>(CItemToolAxe.java:13) at net.enderlook.extracraft.items.items.tools.ItemFlintAxe.<init>(ItemFlintAxe.java:18) at net.enderlook.extracraft.items.init.CItems.<clinit>(CItems.java:67) [...] The CommonProxy.java:49 line is: CItems.registerItems(event); Which calls: public static void registerItems(final RegistryEvent.Register<Item> event) { // CItems class final IForgeRegistry<Item> registry = event.getRegistry(); //... registry.registerAll(ITEMS_TOOL_AXE); //... } And ITEMS_TOOL_AXE is this array: public static final CItemToolAxe[] ITEMS_TOOL_AXE = new CItemToolAxe[] { // CItems class ITEM_FLINT_AXE }; Where ITEM_FLINT_AXE is this item: @ObjectHolder(ExtraCraft.MOD_ID + ":flint_axe") // CItems class public static final ItemFlintAxe ITEM_FLINT_AXE = new ItemFlintAxe("flint_axe"); And ItemFlintAxe's class extends from my base class: public class CItemToolAxe extends ItemAxe implements IInitModel { public CItemToolAxe(String unlocalizedName, CreativeTabs tab, ToolMaterial material) { //... } @Override @SideOnly(Side.CLIENT) public void initializeModel() { // This comes from IInitModel ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory")); } } Also, maybe another relevant line is: @SideOnly(Side.CLIENT) public static void initializeItemsModels() { // CItems class //... for (IInitModel item : ITEMS_TOOL_AXE) { item.initializeModel(); }; //... } Which is called in the ClientProxy class registerModels method. I've read that java.lang.ArrayIndexOutOfBoundsException: 5 is usually caused when you do something like this: int[] array = new int[5]; int boom = array[5]; // Because it count for 0, so the fifth item is the 4 number Or in a loop like: for (int i = 0; i<=name.length; i++) {} // i should start in i = 1 But I didn't do any of both things, right?
-
Ok, a bit stupid my question, but, which of both is more common to use? Also, I'll say this in order to maintain a record in the topic for future read: a person has sent me a private message (not sure why he didn't post in the topic, but thanks anyway) saying I could also use: ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(Items.BOWL)); Which is better because if the inventory is full the item will be drop on the floor. So, is that line better than the others?
-
I'm designing a new food which is a soup, so after eating the soup, the player must get in its inventory an empty bowl. The thing is that I've found two ways of adding the item in the inventory and I want to know which of them is "better": @Override protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) { super.onFoodEaten(stack, worldIn, player); if(!worldIn.isRemote) { // Both commands seems the same player.inventory.addItemStackToInventory(new ItemStack(Items.BOWL)); player.addItemStackToInventory(new ItemStack(Items.BOWL)); } } (I've used "!worldIn.isRemote" because I've read that is a good practice... is that true?) Which method is better?: player.inventory.addItemStackToInventory(ItemStack); player.addItemStackToInventory(ItemStack); Also, I've found "player.inventory.mainInventoryaddItemStackToInventory(ItemStack);" but that crash the game when the food is eaten. This method is inside the class of my custom item ("ItemEggSoup") which inherits from generic class ("TItemFood"), which that inherits from vanilla class ("ItemFood"). Thanks. PD: This is my first time using this forum, so tell me if I've broken any rule, not sure how questions are done here.