Jump to content

[1.16.1] Remove Full Block Collision


NorthWestWind

Recommended Posts

I want to make some vanilla blocks to have no collision under certain condition, so I override the block (in this example, glass block):

public class CustomGlassBlock extends GlassBlock {
    public CustomGlassBlock(Block block) {
        super(Properties.from(block));
    }

    @Override
    public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
        if(/*some condition*/) {
          return VoxelShapes.empty();
        }
        return super.getCollisionShape(state, worldIn, pos, context);
    }
}

As far as I know, returning VoxelShapes.empty() in Block#getCollisionShape will actually make the block have no collision, at least I think that is true.

When testing, the block does have no collision, but it is still pushing me out. What am I missing?

Link to comment
Share on other sites

Block.Properties#doesNotBlockMovement()

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

5 hours ago, NorthWestWind said:

I want to make some vanilla blocks to have no collision under certain condition, so I override the block (in this example, glass block):

Do you want to make the Vanilla block have no collision or your custom block? You cannot modify a vanilla block behaviour by extending the block and overriding a method in your custom block

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

Quote

Do you want to make theย Vanillaย block have no collision or your custom block?

I want to make theย Vanillaย block have no collision.
ย 

Quote

You cannot modify a vanilla block behaviour by extending the block and overriding a method in your custom block

But I do that on other blocks and it works. I extend the block and register the block again.

Link to comment
Share on other sites

Well, if you specify doesNotBlockMovement in the block properties, instead of returning a VoxelShapes#empty under your conditions,you could instead return the collision shape of the block when the condition is not verified. Basically invert what you were doing here:

    @Override
    public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
        if(/*some condition*/) {
          return VoxelShapes.empty();
        }
        return super.getCollisionShape(state, worldIn, pos, context);
    }

ย 

Edited by Beethoven92

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

Well, since you are trying to make the block uncollidable under your conditions, you should check for that condition inside this method (eg check if the player is holding a special item when colliding with your block) and take the appropriate measure.

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

I tried to remove the bounding box of the player byย Entity#setBoundingBoxย inย onEntityCollisionย and it didn't go well.

As soon as I touch the block, my entire game runs at 1 fps and I found myself at the bottom of the world.

I have a feeling that I used the set bounding box method wrongly because I just get the bounding box of the entity and useย AxisAlignedBB#shrinkย to get rid of the bounding box.

Link to comment
Share on other sites

๐Ÿ˜† i guess by removing the entity (your player in this case) bounding box, collision with the ground are not checked anymore, thats why you just sank out of the world. Don't touch the entity bounding box...i was thinking at something like...is there a collision between your block and the player? Is your condition satisfied? ----> get rid of the collision shape of the block , else the block is acting as normal with the collisions and all the rest

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

I did cancel the collision shape of the block (in the very first try) and I'm sure the condition is satisfied since when I have the item, I can clip into the block (and it covers my screen), but there is a force constantly pushing me out and doesn't allow me to walk through the block. Without that item, the block just acts like normal block.

Edited by NorthWestWind
Link to comment
Share on other sites

So...i tried to code that myself and i made it work, but my solution may not be the best or the most elegant one. Turns out that onEntityCollision happens only if the shape of the block is set to be smaller than the full block. So i set two different voxel shapes, a null voxel shape and one that is slightly smaller than the cube, with dimensions:

Block.makeCuboidShape(0.1F, 0.1F, 0.1F, 15.9F, 15.9F, 15.9F)

which doesn't basically change anything visually but lets the collision event happen (For some reason i am still unable to understand). Inside the event i just check for the condition and select the appropriate voxel shape, which then needs to be returned by getShape (not getCollisionShape). It works but as i said before this seems to be a slightly "hacky" solution and also present some issues:

1) you will be able to walk on the border of your block when in its solid form

2) any other entity will be able to walk through your block while you are inside the block with your condition being verified

3) being the voxel shapes static and shared between all blocks of the same type, when you make one of them not solid, if other are present they will all become not solid

Edited by Beethoven92

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

52 minutes ago, Beethoven92 said:

being the voxel shapes static and shared between all blocks of the same type, when you make one of them not solid, if other are present they will all become not solid

It won't

edit: i meant "They won't"

Edited by Crazzy4999
Link to comment
Share on other sites

But you're only doing it for the blockย at a given position.

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

2 minutes ago, Draco18s said:

But you're only doing it for the blockย at a given position.

That's what i was thinking, but after testing with multiple blocks it appears that with my code if i am inside one block (and so its voxel shape its null), all the other blocks also have null voxel shapes ๐Ÿค”

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

I thinkย getShapeย is just used to render the block's outline. It cannot change the collision shape by itself, but sinceย getCollisionShapeย just callย getShapeย by default, overridingย getShapeย also overridesย getCollisionShape.

ย 

I took a look at whatย Properties#doesNotBlockMovementย does before and turns out it only changes the collision shape, not the shape itself. A good example would be torches because they have no collision, but at the same time have an outline.

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

    • Tambang88 adalah pilihan terbaik bagi Anda yang mencari pengalaman bermain slot gacor dengan transaksi mudah menggunakan Bank Sinarmas. Berikut adalah beberapa alasan mengapa Anda harus memilih Tambang88: Raja Slot Gacor Kami merupakan raja slot gacor dengan koleksi permainan terbaik yang menawarkan kesenangan bermain dan peluang kemenangan besar. Dengan fitur-fitur unggulan dan tema-tema menarik, setiap putaran permainan akan memberikan Anda pengalaman yang tak terlupakan. Transaksi Mudah dengan Bank Sinarmas Kami menyediakan layanan transaksi mudah melalui Bank Sinarmas untuk kenyamanan dan keamanan Anda. Dengan proses yang cepat dan efisien, Anda dapat melakukan deposit dan penarikan dana dengan lancar dan tanpa hambatan. Profesional dan Menguntungkan Tambang88 mengutamakan profesionalitas dalam memberikan layanan kepada para pemainnya. Kami juga menawarkan kesempatan untuk meraih keuntungan yang besar dengan jackpot dan hadiah-hadiah menarik lainnya. ย  ย 
    • TRIK POLA SL0T GAC0R MAHJONG WAYS 1 DAN 2 HARI INI Sekarang Anda dapat meningkatkan peluang Bermain dengan langsung menggunakan situs resmi dari permainan Mahjong (PG SOFT). Cukup daftar dan siapkan hanya mulai dari 50K hingga 200K, Anda sudah memiliki peluang untuk memenangkan hadiah besar. Jika tidak memiliki dana sebanyak itu, Anda dapat mencoba dengan dana 50K dan memanfaatkan bonus member baru untuk menambah modal. Berikut adalah Situs Resmi Mahjong yang dapat Anda kunjungi: >> SITUS RESMI MAHJONG YANG TERBUKTI << >> SITUS RESMI MAHJONG YANG TERBUKTI << Setelah mendaftar, Anda dapat menggunakan pola yang sering saya gunakan: ๐Ÿ”ฅ 25 Manual TURBO OFF ๐Ÿ”ฅ 15 Manual TURBO ON ๐Ÿ”ฅ 30 Auto TURBO OFF ๐Ÿ”ฅ 10 Manual TURBO ON Pola ini biasanya memberikan hasil yang konsisten.
    • OLO4D adalah pilihan terbaik bagi Anda yang mencari pengalaman bermain slot gacor dengan transaksi mudah menggunakan Bank Bukopin. Berikut adalah beberapa alasan mengapa Anda harus memilih OLO4D: Slot Gacor Terbaik Kami menyajikan koleksi slot gacor terbaik yang menawarkan kesenangan bermain dan peluang kemenangan besar. Dengan fitur-fitur unggulan dan tema-tema menarik, setiap putaran permainan akan memberikan Anda pengalaman yang tak terlupakan. Transaksi Mudah dengan Bank Bukopin Kami menyediakan layanan transaksi mudah melalui Bank Bukopin untuk kenyamanan dan keamanan Anda. Dengan proses yang cepat dan efisien, Anda dapat melakukan deposit dan penarikan dana dengan lancar dan tanpa hambatan. Pasti Jackpot OLO4D memberikan jaminan bahwa setiap pemain pasti mendapatkan jackpot. Dengan peluang kemenangan yang tinggi, setiap putaran permainan bisa menjadi peluang untuk meraih keberuntungan besar. ย 
    • Balon168: Gampang Banjir Scatter Hitam Malam Ini Balon168 telah menjadi sorotan dalam dunia perjudian online, dan ada alasan kuat mengapa pemain semakin tertarik. Salah satu permainan unggulannya, yang dikenal dengan tingkat kemenangan yang tinggi, adalah varian "Gampang Banjir Scatter Hitam Malam Ini". Mari kita selami lebih dalam mengenai fenomena ini. Balon168: Destinasi Utama bagi Pecinta Slot ย  ย  DAFTAR SEKARANG LINK VIP MAXWIN ย 
    • BALON168๐ŸŽˆ: Situs Slot Gacor Terbaik, Termewah, dan Tergacor 2024 dengan RTP 99,99% Mudah Maxwin Jika Anda pencinta judi online, mencari situs yang dapat diandalkan dan memberikan pengalaman bermain yang memuaskan tentu menjadi prioritas. Salah satu opsi terbaik yang patut dipertimbangkan adalah BALON168๐ŸŽˆ. Situs ini tidak hanya menawarkan berbagai permainan slot yang menarik, tetapi juga mempersembahkan keunggulan dan kenyamanan bagi para pemainnya. Keunggulan BALON168๐ŸŽˆ BALON168๐ŸŽˆ tidak hanya sekadar situs slot online biasa. Dengan reputasi yang solid dan terpercaya, BALON168๐ŸŽˆ telah menjadi destinasi favorit bagi para penggemar judi online di tahun 2024. Keunggulan yang ditawarkan mencakup: 1. RTP Tinggi 99,99% Salah satu hal yang membuat BALON168๐ŸŽˆ menonjol adalah tingkat pengembalian (RTP) yang luar biasa tinggi, mencapai 99,99%. Ini berarti pemain memiliki peluang besar untuk memenangkan hadiah besar setiap kali mereka memutar gulungan di slot BALON168๐ŸŽˆ. 2. Permainan Slot Gacor BALON168๐ŸŽˆ dikenal sebagai situs slot gacor terbaik di tahun 2024. "Gacor" adalah istilah yang digunakan untuk mesin slot yang sering memberikan kemenangan kepada pemainnya. Dengan koleksi permainan slot yang beragam dan sering memberikan jackpot besar, BALON168๐ŸŽˆ memastikan pengalaman bermain yang memuaskan bagi para pengunjungnya. 3. Maxwin yang Mudah Di BALON168๐ŸŽˆ, peluang maxwin tidak hanya menjadi impian belaka. Dengan fitur yang mudah dimengerti dan diakses, pemain memiliki kesempatan yang besar untuk meraih kemenangan maksimum dalam setiap permainan yang mereka mainkan. Keamanan dan Kepuasan Pemain BALON168๐ŸŽˆ mengutamakan keamanan dan kepuasan para pemainnya. Dengan sistem keamanan terkini dan perlindungan data yang canggih, para pemain dapat bermain dengan tenang tanpa khawatir tentang privasi dan keamanan mereka. Layanan pelanggan yang responsif dan ramah juga selalu siap membantu para pemain dalam setiap masalah atau pertanyaan yang mereka miliki. ย  ย  ย  โฑโฑโฑโฑโฑ DAFTAR DI SINI โฐโฐโฐโฐโฐ โฑโฑโฑโฑโฑ DAFTAR AKUN PRO โฐโฐโฐโฐโฐ โฑโฑโฑโฑโฑ DAFTAR AKUN VIPย โฐโฐโฐโฐโฐ ย  ย  ย  ย  ย  ย 
  • Topics

×
×
  • Create New...

Important Information

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