Posted February 4, 20178 yr After tinkering for a couple days I have everything working with the addSubstitutionAlias method. So I started substituting blocks and ran into the odd limitation of only being able to substitute 19 blocks. I wrote some test/example code to show the problem (below). Sure enough, if I substitute 19 of the blocks it works great. Add a 20th substitution and I get java.lang.NullPointerException: Initializing game (also below). I also tried the code in the latest 1.11.2 build and got the same thing. Any advice? I'm pretty new here, is there somewhere I should report this as an error? Thanks. package com.example.examplemod; import net.minecraft.block.Block; import net.minecraft.block.BlockOre; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.ExistingSubstitutionException; import net.minecraftforge.fml.common.registry.GameRegistry; @Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION) public class ExampleMod { public static final String MODID = "examplemod"; public static final String VERSION = "1.0"; @EventHandler public void preInit(FMLPreInitializationEvent event) { substitute(Blocks.COBBLESTONE, new ModBlock("stonebrick")); substitute(Blocks.LAPIS_BLOCK, new ModBlock("blockLapis")); substitute(Blocks.GOLD_BLOCK, new ModBlock("blockGold")); substitute(Blocks.IRON_BLOCK, new ModBlock("blockIron")); substitute(Blocks.BRICK_BLOCK, new ModBlock("brick")); substitute(Blocks.MOSSY_COBBLESTONE, new ModBlock("stoneMoss")); substitute(Blocks.DIAMOND_BLOCK, new ModBlock("blockDiamond")); substitute(Blocks.END_STONE, new ModBlock("whiteStone")); substitute(Blocks.EMERALD_BLOCK, new ModBlock("blockEmerald")); substitute(Blocks.COAL_BLOCK, new ModBlock("blockCoal")); substitute(Blocks.PURPUR_BLOCK, new ModBlock("purpurBlock")); substitute(Blocks.END_BRICKS, new ModBlock("endBricks")); substitute(Blocks.NETHER_WART_BLOCK, new ModBlock("netherWartBlock")); substitute(Blocks.GOLD_ORE, new ModBlockOre("oreGold")); substitute(Blocks.IRON_ORE, new ModBlockOre("oreIron")); substitute(Blocks.COAL_ORE, new ModBlockOre("oreCoal")); substitute(Blocks.LAPIS_ORE, new ModBlockOre("oreLapis")); substitute(Blocks.DIAMOND_ORE, new ModBlockOre("oreDiamond")); substitute(Blocks.EMERALD_ORE, new ModBlockOre("oreEmerald")); substitute(Blocks.QUARTZ_ORE, new ModBlockOre("netherquartz")); } public static void substitute(Block toReplace, Block newBlock) { substitute(toReplace, newBlock, new ItemBlock(newBlock)); } public static void substitute(Block toReplace, Block newBlock, Item newItem) { try { ResourceLocation oldName = Block.REGISTRY.getNameForObject(toReplace); String nameToSubstitute = oldName.toString(); String nameToRegister = ExampleMod.MODID + ":" + oldName.getResourcePath(); newBlock.setRegistryName(nameToRegister); GameRegistry.addSubstitutionAlias(nameToSubstitute.toString(), GameRegistry.Type.BLOCK, newBlock); newItem.setRegistryName(nameToRegister); GameRegistry.addSubstitutionAlias(nameToSubstitute.toString(), GameRegistry.Type.ITEM, newItem); } catch (ExistingSubstitutionException e) { e.printStackTrace(); throw new RuntimeException(e); } } public static class ModBlock extends Block { public ModBlock(String name) { super(Material.ROCK); this.setUnlocalizedName(name); } } public static class ModBlockOre extends BlockOre { public ModBlockOre(String name) { this.setUnlocalizedName(name); } } } The error Spoiler Description: Initializing game java.lang.NullPointerException: Initializing game at net.minecraft.client.renderer.block.model.ModelResourceLocation.<init>(ModelResourceLocation.java:24) at net.minecraft.client.renderer.block.statemap.DefaultStateMapper.getModelResourceLocation(DefaultStateMapper.java:15) at net.minecraft.client.renderer.block.statemap.StateMapperBase.putStateModelLocations(StateMapperBase.java:56) at net.minecraft.client.renderer.block.statemap.BlockStateMapper.getVariants(BlockStateMapper.java:74) at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:122) at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:229) at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:146) at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:122) at net.minecraft.client.Minecraft.startGame(Minecraft.java:539) at net.minecraft.client.Minecraft.run(Minecraft.java:385) 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.client.renderer.block.model.ModelResourceLocation.<init>(ModelResourceLocation.java:24) at net.minecraft.client.renderer.block.statemap.DefaultStateMapper.getModelResourceLocation(DefaultStateMapper.java:15) at net.minecraft.client.renderer.block.statemap.StateMapperBase.putStateModelLocations(StateMapperBase.java:56) at net.minecraft.client.renderer.block.statemap.BlockStateMapper.getVariants(BlockStateMapper.java:74) at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:122) at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:229) at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:146) at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:122) at net.minecraft.client.Minecraft.startGame(Minecraft.java:539) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:385) 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.11 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_121, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 1000360648 bytes (954 MB) / 1282408448 bytes (1223 MB) up to 3804758016 bytes (3628 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.35 Powered by Forge 13.19.1.2189 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.11-13.19.1.2189.jar) UCH forge{13.19.1.2189} [Minecraft Forge] (forgeSrc-1.11-13.19.1.2189.jar) UCH examplemod{1.0} [Example Mod] (bin) Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 376.33' Renderer: 'GeForce GTX 770/PCIe/SSE2' Launched Version: 1.11 LWJGL: 2.9.4 OpenGL: GeForce GTX 770/PCIe/SSE2 GL version 4.5.0 NVIDIA 376.33, NVIDIA Corporation 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: 8x Intel(R) Core(TM) i7-2700K CPU @ 3.50GHz [14:22:41] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: #@!@# Game crashed! Crash report saved to: #@!@# D:\Dev\Forge Mods\example-1.11-13.19.1.2189\run\.\crash-reports\crash-2017-02-04_14.22.41-client.txt AL lib: (EE) alc_cleanup: 1 device not closed Edited February 5, 20178 yr by Vryday_Vrything Clarification
February 5, 20178 yr Author I've never used github so I hope this is okay... apologies if not... addSubstitutionAlias-example As for why. I made an algorithm that contours the blocks a bit. Long story short, I want to change the collision boxes returned by the vanilla blocks to match the contoured terrain better. It's also much cleaner to change out the blocks for the rendering aspect, though not strictly necessary I don't think. Edited February 5, 20178 yr by Vryday_Vrything link update
February 5, 20178 yr Author Awesome, thank you. I'll try to do it without substitution again. If I may ask one more question... do you know a good way in forge to catch specific blocks in an event? I was going to implement an interface on the substituted blocks. Without substitution the only idea I have is to keep a large list of blocks I want to catch at specific points and iterate over it every time. Seems excessive...
February 5, 20178 yr Author Unfortunately, while using GetCollisionBoxesEvent I still noticed collisions with many blocks when I clear the entire collision list (as a test). <EDIT> It appears this is because Block#isNormalCube still evaluates to true... EntityPlayerSp#pushOutOfBlocks calls EntityPlayerSp#isHeadspaceFree calls EntityPlayerSp#isOpenBlockSpace calls Block#isNormalCube </EDIT> Also, there doesn't appear to be an event for raytracing, which is unfortunate but, perhaps, not absolutely critical... As I feared, it appears this solution will not work either... but thanks again anyway diesieben07. I'll explore some of the earlier forge releases in hopes that one of these solutions will work. Or perhaps I will just use my own world gen and duplicate all the blocks. Though that would be a shame as I believe it would be more difficult to use my mod with other mods... EDIT I've experimented with the substitution limit more and hacked past the limitation for now... I hope to find a more legitimate solution in the future... Edited February 7, 20178 yr by Vryday_Vrything update
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.