Jump to content

[1.11.2] [Solved] Shadows rendering around non-opaque non-full custom block


CorwinJ

Recommended Posts

From what I understand using useNeighborBrightness and isFullBlock should be enough to make this work but I'm having issues:

 

public class PathBlock extends ModBlock {
    private static final AxisAlignedBB PATH_AABB = new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 0.3, 1.0);

    PathBlock()
    {
        super(Material.ROCK);
        this.setHardness(4.0f);
        this.setSoundType(SoundType.STONE);
        this.setLightOpacity(0);
        this.useNeighborBrightness = true;
        this.fullBlock = false;
    }

    // Rendering stuff
    @Override
    public boolean isFullyOpaque(IBlockState state) {
        return false;
    }

    @Override
    public boolean isFullBlock(IBlockState state) {
        return false;
    }

    @Override
    public boolean isOpaqueCube(IBlockState state) {
        return false;
    }

    public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face)
    {
        return false;
    }

    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
    {
        return PATH_AABB;
    }
}

 

The base class:

public class ModBlock extends Block
{
    public ModBlock(Material aMaterial) {
        super(aMaterial);
        this.init();
    }

    public ModBlock()
    {
        super(Material.WOOD);
        this.init();
    }

    public void init()
    {
        this.setCreativeTab(CreativeTab.ATB_TAB);
    }

    @Override
    public String getUnlocalizedName()
    {
        return String.format("tiles.%s%s", Reference.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
    }

    protected String getUnwrappedUnlocalizedName(String unlocalizedName)
    {
        return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
    }
}

 

Model JSON:

{
    "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
    "textures": {
        "0": "blocks/stone",
	"particle": "blocks/stone"
    },
    "elements": [
        {
            "name": "Cube",
            "from": [ 2.0, 0.0, 2.0 ],
            "to": [ 5.0, 1.0, 7.0 ],
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 5.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 5.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 5.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 5.0 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 7.0, 0.0, 6.0 ],
            "to": [ 10.0, 1.0, 11.0 ],
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 5.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 5.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 5.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 5.0 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 12.0, 0.0, 10.0 ],
            "to": [ 15.0, 1.0, 15.0 ],
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 5.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 5.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 5.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 5.0 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 12.0, 0.0, 2.0 ],
            "to": [ 15.0, 1.0, 5.0 ],
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 3.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 3.0 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 11.0, 0.0, 2.0 ],
            "to": [ 12.0, 1.0, 3.0 ],
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 5.0, 0.0, 4.0 ],
            "to": [ 6.0, 1.0, 5.0 ],
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 6.0, 0.0, 9.0 ],
            "to": [ 7.0, 1.0, 11.0 ],
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 2.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 2.0 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 11.0, 0.0, 13.0 ],
            "to": [ 12.0, 1.0, 14.0 ],
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 3.0, 0.0, 11.0 ],
            "to": [ 5.0, 1.0, 14.0 ],
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 3.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 3.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 3.0 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 7.0, 0.0, 13.0 ],
            "to": [ 9.0, 1.0, 15.0 ],
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 2.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 2.0 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 8.0, 0.0, 3.0 ],
            "to": [ 10.0, 1.0, 5.0 ],
            "shade": false,
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 2.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 2.0 ] }
            }
        }
    ]
}

 

What I'm seeing:

SNIc6o8.png

Link to comment
Share on other sites

I'm not sure this is it, but there is a shade tag that you can set to false for each element in the model. The wiki reads this:

shade: Defines if shadows are rendered (true - default), not (false).

 

While this is true, that's not actually what that does.  The "shade" tag is what controls whether the block's model itself uses lighting information or is fullbright (i.e. even in a pitch dark room you can still see it, as if the block itself was "glowing").

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I'm not sure this is it, but there is a shade tag that you can set to false for each element in the model. The wiki reads this:

shade: Defines if shadows are rendered (true - default), not (false).

 

Ah I see, makes sense

 

While this is true, that's not actually what that does.  The "shade" tag is what controls whether the block's model itself uses lighting information or is fullbright (i.e. even in a pitch dark room you can still see it, as if the block itself was "glowing").

Link to comment
Share on other sites

I'm not sure this is it, but there is a shade tag that you can set to false for each element in the model. The wiki reads this:

shade: Defines if shadows are rendered (true - default), not (false).

 

Tested that and yeah, no change in the way it rendered. The "ambientocclusion" tag on the model made the texture fullbright but didn't effect the shadowing xD.

Link to comment
Share on other sites

For reference, this is how I'm registering my block. Maybe there's something wrong there?

 

At the top of my ModBlocks.java

    public static final Block PATH_BLOCK = new PathBlock().setUnlocalizedName(PATH_BLOCK_TAG);

 

In preInit:

        GameRegistry.register(PATH_BLOCK.setRegistryName(new ResourceLocation(Reference.MOD_ID, PATH_BLOCK_TAG)));
        GameRegistry.register(new ItemBlock(PATH_BLOCK), PATH_BLOCK.getRegistryName());

 

In init (thru a proxy):

    registerRender(PATH_BLOCK, PATH_BLOCK_TAG);

    private static void registerRender(Block block, String key)
    {
        Item item = Item.getItemFromBlock(block);

        Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
                .register(item,
                        0,
                        new ModelResourceLocation(Reference.RESOURCE_PREFIX + key, "inventory"));
    }

Link to comment
Share on other sites

Minecraft.getMinecraft().getRenderItem().getItemModelMesher()

 

You also shouldn't use the ModelMesher, you should use ModelLoader.setCustomModelResourceLocation

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Minecraft.getMinecraft().getRenderItem().getItemModelMesher()

 

You also shouldn't use the ModelMesher, you should use ModelLoader.setCustomModelResourceLocation

 

Switching to ModelLoader.setCustomModelResourceLocation makes all of the items render as MissingTexture/Model blocks. Do I have to change my item jsons?

 

My current item json:

{
  "parent": "mymod:block/pathblock",
  "display": {
    "thirdperson_righthand": {
      "rotation": [ 62, 41, 0 ],
      "translation": [ 0, 0, 0 ],
      "scale": [ 0.4, 0.4, 0.4 ]
    },
    "thirdperson_lefthand": {
      "rotation": [ 62, 41, 0 ],
      "translation": [ 0, 0, 0 ],
      "scale": [ 0.4, 0.4, 0.4 ]
    },
    "ground": {
      "rotation": [ 0, 0, 0 ],
      "translation": [ 0, 0, 0 ],
      "scale": [ 1, 1, 1 ]
    },
    "fixed": {
      "rotation": [ 0, 0, 0 ],
      "translation": [ 0, 0, 0 ],
      "scale": [ 1, 1, 1 ]
    },
    "firstperson_righthand": {
      "rotation": [ 10, 48, -3 ],
      "translation": [ -1.89, 0, 0 ],
      "scale": [ 0.38, 0.38, 0.38 ]
    },
    "firstperson_lefthand": {
      "rotation": [ 10, 48, -3 ],
      "translation": [ -1.89, 0, 0 ],
      "scale": [ 0.38, 0.38, 0.38 ]
    },
    "gui": {
      "rotation": [ 30, 45, 0 ],
      "translation": [ 0, 0, 0],
      "scale":[ 0.6, 0.6, 0.6 ]
    }
  }
}

Link to comment
Share on other sites

No, you have to do it in

ModelRegistryEvent

. Note that you will need to use

@EventBusSubscriber

to subscribe to this event, registering for it in preInit is too late. Read the Event Documentation if you are unfamiliar with

@EventBusSubscriber

.

 

I've got the ModelRegistryEvent firing and I'm using setCustomModelResourceLocation. Not seeing any errors but still pink missing textures.

@Mod.EventBusSubscriber(Side.CLIENT)
public class ModelRenders {
    @SubscribeEvent
    public static void registerRenders(ModelRegistryEvent e)
    {
        Item item = Item.getItemFromBlock(PATH);
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(Reference.RESOURCE_PREFIX + "pathblock", "inventory"));
    }
}

 

And I've changed around my block registration;

In my ModBlocks class:

    public static final Block PATH              = new PathBlock().setUnlocalizedName("pathblock");

 

preInit:

        GameRegistry.register(PATH.setRegistryName(new ResourceLocation(Reference.MOD_ID, "pathblock")));
        GameRegistry.register(new ItemBlock(PATH), PATH.getRegistryName());

 

I think the problem might be that the item block is being registered too late for the ModelRegistryEvent?

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.

Announcements



×
×
  • Create New...

Important Information

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