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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Slot Deposit 1000: Slot Online Gacor Modal Receh Minimal Deposit 1000 1rb 2rb 3rb 5rb Tanpa Potongan Terbaru ▶️▶️DAFTAR◀️◀️ ▶️▶️DAFTAR◀️◀️ Bagi para penggemar slot online yang mencari pengalaman bermain yang mengasyikkan tanpa harus mengeluarkan modal besar, Lambo77 adalah tempat yang tepat. Dengan menawarkan slot deposit 1000, Lambo77 memungkinkan pemain untuk memulai petualangan mereka dengan modal yang terjangkau. Dengan minimal deposit hanya 1000, pemain dapat menikmati berbagai permainan slot favorit mereka tanpa perlu khawatir tentang kekurangan modal. Terlebih lagi, Lambo77 menawarkan berbagai pilihan nominal deposit, mulai dari 1rb hingga 5rb, sehingga pemain memiliki fleksibilitas dalam mengelola bankroll mereka. Salah satu keunggulan utama bermain di Lambo77 adalah tidak adanya potongan dalam setiap transaksi deposit. Hal ini memastikan bahwa pemain dapat menggunakan seluruh jumlah deposit mereka untuk bermain, tanpa harus kehilangan sebagian karena biaya tambahan. Dengan fitur-fitur seperti ini, Lambo77 menjadikan pengalaman bermain slot online semakin menghibur dan menguntungkan bagi para pemain. Jadi, jangan ragu untuk mencoba keberuntungan Anda dan mulai petualangan slot Anda di Lambo77 hari ini!  
    • Selamat datang di GACOR268 salah satu situs slot gacor gampang menang hari ini di Indonesia yang sangat menjajikan. Slot gacor adalah adalah suatu istilah yang digunakan untuk menjelaskan sebuah permainan slot gampang menang di situs slot online. Situs slot gacor GACOR268 ini bisa menjadi populer walaupun terbilang baru karena RTP slot online yang disajikan begitu tinggi. Seiring dengan perkembangan zaman situs slot gacor terbaru ini juga sudah update dari segi teknologi yang menggunakan HTML5, inilah yang membuat grafis permainan terlihat begitu modern, audio lebih jernih, dan user interface yang smooth. Tidak dipungkiri grafis yang kami memiliki sudah menarik banyak sekali pendatang baru yang ingin merasakan terbawa dalam suasana tema permainan mesin slot. Kehadiran slot gacor menjadi angin segar bagi para pecinta judi online, memberikan alternatif permainan yang seru dan menguntungkan. Tak heran jika popularitas slot gacor terus meningkat, menarik minat para pemain baru untuk mencoba peruntungan mereka di situs slot gacor hari ini GACOR268.
    • Slot BCA Lambo77 = Link Daftar Slot BCA Modal Receh Auto Jackpot Deposit bank BCA Tanpa Potongan 2024 ▶️▶️DAFTAR◀️◀️ ▶️▶️DAFTAR◀️◀️ Lambo77 telah menjadi tujuan utama bagi para penggemar slot online yang mencari pengalaman bermain yang aman dan terpercaya menggunakan Bank BCA. Sebagai salah satu situs slot online terkemuka di tahun 2024, Lambo77 menawarkan akses mudah dan cepat untuk melakukan deposit dan menikmati berbagai permainan slot berkualitas. Dengan layanan deposit menggunakan Bank BCA, pemain dapat dengan nyaman melakukan transaksi ke akun mereka tanpa khawatir tentang keamanan atau keandalan. Lambo77 menjamin proses transaksi yang lancar dan aman, sehingga pemain dapat fokus sepenuhnya pada pengalaman bermain mereka. Selain itu, Lambo77 juga menyediakan beragam permainan slot yang menarik dengan fitur-fitur bonus yang menggiurkan. Dari slot klasik hingga yang paling modern, pemain dapat menemukan berbagai pilihan permainan yang sesuai dengan selera dan preferensi mereka. Dengan reputasi yang solid dan komitmen untuk memberikan pengalaman bermain yang terbaik, Lambo77 terus menjadi pilihan utama bagi para penggemar slot online di tahun 2024. Jadi, jangan ragu untuk bergabung dengan Lambo77 dan rasakan sensasi menang yang tak terlupakan di setiap putaran!  
    • Selamat datang di Gacor88 salah satu situs slot gacor gampang menang hari ini di Indonesia yang sangat menjajikan. Slot gacor adalah adalah suatu istilah yang digunakan untuk menjelaskan sebuah permainan slot gampang menang di situs slot online. Situs slot gacor Gacor88 ini bisa menjadi populer walaupun terbilang baru karena RTP slot online yang disajikan begitu tinggi. Seiring dengan perkembangan zaman situs slot gacor terbaru ini juga sudah update dari segi teknologi yang menggunakan HTML5, inilah yang membuat grafis permainan terlihat begitu modern, audio lebih jernih, dan user interface yang smooth. Tidak dipungkiri grafis yang kami memiliki sudah menarik banyak sekali pendatang baru yang ingin merasakan terbawa dalam suasana tema permainan mesin slot. Kehadiran slot gacor menjadi angin segar bagi para pecinta judi online, memberikan alternatif permainan yang seru dan menguntungkan. Tak heran jika popularitas slot gacor terus meningkat, menarik minat para pemain baru untuk mencoba peruntungan mereka di situs slot gacor hari ini Gacor88.
    • Selamat datang di Casino88 salah satu situs slot gacor gampang menang hari ini di Indonesia yang sangat menjajikan. Slot gacor adalah adalah suatu istilah yang digunakan untuk menjelaskan sebuah permainan slot gampang menang di situs slot online. Situs slot gacor Casino88 ini bisa menjadi populer walaupun terbilang baru karena RTP slot online yang disajikan begitu tinggi. Seiring dengan perkembangan zaman situs slot gacor terbaru ini juga sudah update dari segi teknologi yang menggunakan HTML5, inilah yang membuat grafis permainan terlihat begitu modern, audio lebih jernih, dan user interface yang smooth. Tidak dipungkiri grafis yang kami memiliki sudah menarik banyak sekali pendatang baru yang ingin merasakan terbawa dalam suasana tema permainan mesin slot. Kehadiran slot gacor menjadi angin segar bagi para pecinta judi online, memberikan alternatif permainan yang seru dan menguntungkan. Tak heran jika popularitas slot gacor terus meningkat, menarik minat para pemain baru untuk mencoba peruntungan mereka di situs slot gacor hari ini Casino88.
  • Topics

×
×
  • Create New...

Important Information

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