Posted December 1, 20222 yr Let's say I have those 2 variables: ServerLevel level = source.getLevel(); BlockState block = level.getBlockState(levelPosition); I want to make block near one I got (in any direction) temporarily invisible, perform some actions with block I have and then make invisible one visible again. How can I do this?
December 1, 20222 yr Well, the scenario... It's quite complicated. You can view the whole source code here: https://github.com/Dreadoom/RenderCube I am interested in this piece of code: // Min and max coordinates over each axes int region_min_x = Math.min(position1.getX(), position2.getX()); int region_max_x = Math.max(position1.getX(), position2.getX()); int region_min_y = Math.min(position1.getY(), position2.getY()); int region_max_y = Math.max(position1.getY(), position2.getY()); int region_min_z = Math.min(position1.getZ(), position2.getZ()); int region_max_z = Math.max(position1.getZ(), position2.getZ()); // Loop over coordinates for(int x = region_min_x; x <= region_max_x; x++){ for(int y = region_min_y; y <= region_max_y; y++){ for(int z = region_min_z; z <= region_max_z; z++){ // Current block position BlockPos position = new BlockPos(x, y, z); // Process block boolean success = RenderCubeUtils.renderBlock( source, jsonWriter, position, new BlockPos( position.getX() - region_min_x, position.getY() - region_min_y, position.getZ() - region_min_z)); // We finish with success only if RenderCubeUtils.RenderBlock(...) returned true if(!success){ // Finish with failure return -1; } } } } I want it to look something like this: // Min and max coordinates over each axes int region_min_x = Math.min(position1.getX(), position2.getX()); int region_max_x = Math.max(position1.getX(), position2.getX()); int region_min_y = Math.min(position1.getY(), position2.getY()); int region_max_y = Math.max(position1.getY(), position2.getY()); int region_min_z = Math.min(position1.getZ(), position2.getZ()); int region_max_z = Math.max(position1.getZ(), position2.getZ()); // Loop over coordinates for(int x = region_min_x; x <= region_max_x; x++){ for(int y = region_min_y; y <= region_max_y; y++){ for(int z = region_min_z; z <= region_max_z; z++){ // Current block position BlockPos position = new BlockPos(x, y, z); if(x == region_min_x){ makeInvisible(position.mutable().setWithOffset(position, Direction.WEST))); } // Same for other 5 vars // Process block boolean success = RenderCubeUtils.renderBlock( source, jsonWriter, position, new BlockPos( position.getX() - region_min_x, position.getY() - region_min_y, position.getZ() - region_min_z)); if(x == region_min_x){ makeVisible(position.mutable().setWithOffset(position, Direction.WEST))); } // Same for other 5 vars // We finish with success only if RenderCubeUtils.RenderBlock(...) returned true if(!success){ // Finish with failure return -1; } } } } Edited December 1, 20222 yr by Sireous
December 2, 20222 yr so instead of typing "i have a multiblock and want to temporarily remove the boring outer shell to show some fancy-shmancy animation" you decided to go with "here's a bunch of code, work it out"? if the shell block are your blocks, you can set aside one block state for invisible mode (model with zero cubes). if they are vanilla blocks, either memorize them and remove for a while, or, when the multiblock is formed, replace shell blocks with block entities that hold their data and emulate their look.
December 10, 20222 yr Well, I inserted bunch of code to just point out the place, where I want this to happen, because I my opinion task "make block at BlockPosition invisible" is quite scenario independent. I was asking if something like level.setBlockInvisible(position) is possible (level is instance of ServerLevel).
December 10, 20222 yr 3 hours ago, Sireous said: I was asking if something like level.setBlockInvisible(position) is possible nope.
December 11, 20222 yr The redstone lampa Block features an light on and light off set mechanic. in this process the texture is changed. Look for Blockstates. To change between the texture of an invisible block to a visible block, just make the first blockstate textured and the second blockstate invisible texture (invisible texture is different from no texture!!!!). If your game gets too heavy, looking for Entity Blocks might help. Edited December 11, 20222 yr by DouglasRafael
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.