Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jrpetrick

Members
  • Joined

  • Last visited

Everything posted by jrpetrick

  1. This the final solution I have decided to use and no longer need to have empty json files. <code> public class CommonProxy { public void init() { } . . . </code> <code> public class ClientProxy extends CommonProxy { public void init() { MinecraftForge.EVENT_BUS.register(this); BlockModelShapes shapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes(); shapes.registerBuiltInBlocks(new Block[] {ModBlocks.crusher_extension}); . . . </code> <code> @EventHandler public void init(FMLInitializationEvent e) { proxy.registerRenderers(); ModBlocks.init(); proxy.init(); . . . </code>
  2. I did some digging and found hard coded blocks not being added to map model locations so that the variants are not loaded. net.minecraftforge.client.model.ModelLoader.java <code> private void loadBlocks() { Map<IBlockState, ModelResourceLocation> stateMap = blockModelShapes.getBlockStateMapper().putAllStateModelLocations(); loadVariants(stateMap.values()); } </code> net.minecraft.client.renderer.BlockModelShapes.java <code> public void registerBlockWithStateMapper(Block assoc, IStateMapper stateMapper) { this.blockStateMapper.registerBlockStateMapper(assoc, stateMapper); } public void registerBuiltInBlocks(Block ... builtIns) { this.blockStateMapper.registerBuiltInBlocks(builtIns); } private void registerAllBlocks() { this.registerBuiltInBlocks(new Block[] {Blocks.air, Blocks.flowing_water, Blocks.water, Blocks.flowing_lava, Blocks.lava, Blocks.piston_extension, Blocks.chest, Blocks.ender_chest, Blocks.trapped_chest, Blocks.standing_sign, Blocks.skull, Blocks.end_portal, Blocks.barrier, Blocks.wall_sign, Blocks.wall_banner, Blocks.standing_banner}); this.registerBlockWithStateMapper(Blocks.stone, (new StateMap.Builder()).setProperty(BlockStone.VARIANT).build()); this.registerBlockWithStateMapper(Blocks.prismarine, (new StateMap.Builder()).setProperty(BlockPrismarine.VARIANT).build()); . . . </code> net.minecraft.client.renderer.block.statemap.BlockStateMapper.java <code> public class BlockStateMapper { private Map blockStateMap = Maps.newIdentityHashMap(); private Set setBuiltInBlocks = Sets.newIdentityHashSet(); private static final String __OBFID = "CL_00002478"; public void registerBlockStateMapper(Block p_178447_1_, IStateMapper p_178447_2_) { this.blockStateMap.put(p_178447_1_, p_178447_2_); } public void registerBuiltInBlocks(Block ... p_178448_1_) { Collections.addAll(this.setBuiltInBlocks, p_178448_1_); } public Map putAllStateModelLocations() { IdentityHashMap identityhashmap = Maps.newIdentityHashMap(); Iterator iterator = Block.blockRegistry.iterator(); while (iterator.hasNext()) { Block block = (Block)iterator.next(); if (!this.setBuiltInBlocks.contains(block)) { identityhashmap.putAll(((IStateMapper)Objects.firstNonNull(this.blockStateMap.get(block), new DefaultStateMapper())).putStateModelLocations(block)); } } return identityhashmap; } } </code> But I was able to create some basic json files and have been able to get the block working. blockstates.crusher_extenstion.json <code> { "variants": { } } </code> blocks.crusher_extension.json <code> { "parent": "block/cube_all", "textures": { "all": "tools:blocks/transparent" } } </code> Also on block registry passing in a null reference for the item class so that does require an item json file. <code> GameRegistry.registerBlock(crusher, ItemCrusher.class, "crusher"); GameRegistry.registerBlock(crusher_head, null, "crusher_head"); GameRegistry.registerBlock(crusher_extension, null, "crusher_extension"); </code> Thanks for the help, definitely a good learning experience. Jim
  3. I am still getting an error for a missing json file. Any ideas of where to look next? I have done that with my block and registered my TileEntitySpecialRenderer as follows BlockCrusherMoving.java public class BlockCrusherMoving extends BlockContainer { ClientProxy.java public void registerRenderers() { ClientRegistry.registerTileEntity(TileEntityCrusher.class, "CrusherRenderer", new TileEntityCrusherRenderer()); } Tools.java (Mod Class) @EventHandler public void preInit(FMLPreInitializationEvent e) { proxy.registerRenderers(); GameRegistry.registerBlock(new BlockCrusherBase().setUnlocalizedName("crusherBase"), "crusher"); GameRegistry.registerBlock(new BlockCrusherExtension().setUnlocalizedName("crusherExtension"), "crusher_head"); GameRegistry.registerBlock(new BlockCrusherMoving().setUnlocalizedName("crusherMoving"), "crusher_extension"); GameRegistry.addRecipe(new ItemStack(new BlockCrusherBase()), new Object[] { " z ", "xyx", "xwx", Character.valueOf('z'), new ItemStack(Blocks.obsidian), Character.valueOf('y'), new ItemStack(Items.iron_ingot), Character.valueOf('x'), new ItemStack(Blocks.cobblestone), Character.valueOf('w'), new ItemStack(Items.redstone) }); } But I am still getting the follow error. [15:30:16] [Client thread/WARN]: Unable to load definition tools:crusher_extension#facing=east,type=normal java.lang.RuntimeException: Encountered an exception when loading model definition of model tools:blockstates/crusher_extension.json at net.minecraft.client.resources.model.ModelBakery.getModelBlockDefinition(ModelBakery.java:177) ~[ModelBakery.class:?] at net.minecraft.client.resources.model.ModelBakery.loadVariants(ModelBakery.java:118) [ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:96) [ModelLoader.class:?] at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:69) [ModelLoader.class:?] at net.minecraft.client.resources.model.ModelManager.onResourceManagerReload(ModelManager.java:29) [ModelManager.class:?] at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:124) [simpleReloadableResourceManager.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:471) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:325) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_67] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_67] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_67] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_67] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?] at GradleStart.main(GradleStart.java:45) [start/:?] Caused by: java.io.FileNotFoundException: tools:blockstates/crusher_extension.json at net.minecraft.client.resources.FallbackResourceManager.getAllResources(FallbackResourceManager.java:99) ~[FallbackResourceManager.class:?] at net.minecraft.client.resources.SimpleReloadableResourceManager.getAllResources(SimpleReloadableResourceManager.java:81) ~[simpleReloadableResourceManager.class:?] at net.minecraft.client.resources.model.ModelBakery.getModelBlockDefinition(ModelBakery.java:152) ~[ModelBakery.class:?] ... 16 more
  4. I am trying to create new piston block and I am coping the existing code as a starting point. My question is how or why are there no associated json files for the BlockPistonMoving? When I register my moving block I keep getting an error message expecting a blockstate json file. I am either looking for how to implement my block in the same way without needing the json or any help on what should be in a json file for this block. Any help would be much appreciated. Thanks Jim

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.