Jump to content

Set block as invisible on client side [1.19]


4rmy

Recommended Posts

I am writing a mod that requires that a block be set as invisible on the client side.
My code currently has:

BlockPos pos = new BlockPos(x, y, z);
BlockState blockState = Minecraft.instance().level.getBlockState(pos);
Block block = blockState.getBlock();

but I cannot find a method to make the block invisible.

My event listener is:

@SubscribeEvent
public void onRenderWorld(RenderLevelStageEvent event)

I cannot use 

Minecraft.instance().level.setBlock(block, Blocks.AIR.defaultProperties, 3);

as that did not work.

The block has to be visible to other players.

Edited by 4rmy
Link to comment
Share on other sites

  • 4rmy changed the title to Set block as invisible on client side [1.19]

If you want to have a block that has custom data (who placed the block) and to change the rendering based on that data then you need a BlockEntity.

https://forge.gemwire.uk/wiki/Block_Entities

https://forge.gemwire.uk/wiki/Block_Entity_Renderer

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

1 minute ago, warjort said:

If you want to have a block that has custom data (who placed the block) and to change the rendering based on that data then you need a BlockEntity.

https://forge.gemwire.uk/wiki/Block_Entities

https://forge.gemwire.uk/wiki/Block_Entity_Renderer

I have an item that, when right clicked on a vanilla block, should turn the block invisible. I am not trying to add a new block, but rather change the existing block.

Link to comment
Share on other sites

58 minutes ago, Novality said:

Sounds to me like you're writing a modern x-ray mod.. 🤨

If you have seen an x-ray mod like the one in Meteor client, I am trying to do the same effect, but I am only doing it to certain blocks.

See image:
143770355-23f099fb-9bf3-4062-9837-e9e9f1

Edited by 4rmy
Link to comment
Share on other sites

There is no way to change the rendering for normal blocks individually (beyond major hacks to the game that would likely cause compatiblity problems).

They are all really the same block, just drawn in different places on the screen.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.