Jump to content

[SOLVED] [1.8] Final solution - BlockPistonMoving - json configuration


jrpetrick

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Hi

 

Well that's strange.  if your getRenderType returns -1, I thought it doesn't look for a json.  I could be wrong. 

 

You could get rid of the error message by creating a dummy json which doesn't draw anything, eg has no elements.  Or alternatively if that doesn't work, a json which has a single transparent face.

 

For more info on how to do that see here (the three block rendering topics)

http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html

 

-TGG

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

  • Like 1
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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