Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.19.1] Unable to create a non-opaque block


Adam61
 Share

Recommended Posts

Hi, for several days I have been trying to create a non-opaque block, I have overwritten every type of method: #getOcclusionShape(), #useShapeForLightOcclusion() #isOcclusionShapeFullBlock() and another dozen similar methods but I always get the result in the picture.
I tried to register the lock with both #noOcclusion() and without but without success
ONLY doing getShape() {return Shapes.empty ();} i get the desired result, but I need a full-block shape.

PLS help me 😢

cEpzsYG.png

Link to comment
Share on other sites

All those shapes are mostly used for things like lighting, block/entity collision and hitboxes.

For the rendering you need to change the RenderType, the default is RenderType.SOLID if you don't change it.

 

The old way was to use ItemBlockRenderTypes.setRenderLayer() but that has been deprecated as of 1.19

The recommended way is to put this configuration in your block model json.

   /** @deprecated Set your render type in your block model's JSON (eg. {@code "render_type": "cutout"}) or override {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)} */
   @Deprecated(forRemoval = true, since = "1.19")
   public static void setRenderLayer(Block block, RenderType type) {

 

Link to comment
Share on other sites

Ah so you didn't think showing that was important? 🙂 

You still don't show your block model or the shapes you think should work.

 

I assume your issue is the black part on underside of the top.

Does it kind of work if you put the block on top of a transparent block like glass or even in mid-air so the block beneath is lit?

 

Have you tried telling it the only parts of the block's shape are the top and bottom parts. i.e. pretend the glass looking parts and side bars don't exist.

e.g. try something like this simple shape which is just a thin slice at the top and bottom:

    public static final VoxelShape SHAPE_BOTTOM = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D);
    public static final VoxelShape SHAPE_TOP = Block.box(0.0D, 15.0D, 0.0D, 16.0D, 16.0D, 16.0D);
    public static final VoxelShape SHAPE = Shapes.or(SHAPE_BOTTOM, SHAPE_TOP);

    @Override
    public VoxelShape getShape(BlockState p_60555_, BlockGetter p_60556_, BlockPos p_60557_, CollisionContext p_60558_) {
        return SHAPE;
    }

I am not saying it is the solution (if it even works), only that it might point to where your problem is.

 

But then I am no expert on Minecraft's lighting code. It makes your average tax-code look comprehensible in comparison. 🙂
 

Edited by warjort
Link to comment
Share on other sites

8 minutes ago, warjort said:

Ah so you didn't think showing that was important? 🙂 

You still don't show your block model or the shapes you think should work.

 

I assume your issue is the black part on underside of the top.

Does it kind of work if you put the block on top of a transparent block like glass or even in mid-air so the block beneath is lit?

 

Have you tried telling it the only parts of the block's shape are the top and bottom parts. i.e. pretend the glass looking parts and side bars don't exist.

e.g. try this simple shape which is just a thin slice at the top and bottom:

    public static final VoxelShape SHAPE_BOTTOM = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D);
    public static final VoxelShape SHAPE_TOP = Block.box(0.0D, 15.0D, 0.0D, 16.0D, 16.0D, 16.0D);
    public static final VoxelShape SHAPE = Shapes.or(SHAPE_BOTTOM, SHAPE_TOP);

    @Override
    public VoxelShape getShape(BlockState p_60555_, BlockGetter p_60556_, BlockPos p_60557_, CollisionContext p_60558_) {
        return SHAPE;
    }

I am not saying it is the solution (if it even works), only that it might point to where your problem is.

 

But then I am no expert on Minecraft's lighting code. It makes your average tax-code look comprehensible in comparison. 🙂
 

My block model: 

Spoiler
{
	"credit": "Made with Blockbench",
	"ambientocclusion": false,
	"render_type": "cutout",
	"textures": {
		"0": "block/iron_block",
		"1": "block/glass",
		"particle": "block/iron_block"
	},
	"elements": [
		{
			"from": [0, 15, 0],
			"to": [16, 16, 16],
			"faces": {
				"north": {"uv": [0, 0, 16, 1], "texture": "#0"},
				"east": {"uv": [15, 0, 16, 16], "rotation": 90, "texture": "#0"},
				"south": {"uv": [0, 15, 16, 16], "texture": "#0"},
				"west": {"uv": [0, 0, 1, 16], "rotation": 90, "texture": "#0"},
				"up": {"uv": [0, 0, 16, 16], "texture": "#0"},
				"down": {"uv": [0, 0, 16, 16], "texture": "#0"}
			}
		},
		{
			"from": [0, 0, 0],
			"to": [16, 1, 16],
			"faces": {
				"north": {"uv": [0, 0, 16, 1], "texture": "#0"},
				"east": {"uv": [15, 0, 16, 16], "rotation": 90, "texture": "#0"},
				"south": {"uv": [0, 15, 16, 16], "texture": "#0"},
				"west": {"uv": [0, 0, 1, 16], "rotation": 90, "texture": "#0"},
				"up": {"uv": [0, 0, 16, 16], "texture": "#0"},
				"down": {"uv": [0, 0, 16, 16], "texture": "#0"}
			}
		},
		{
			"from": [0, 1, 15],
			"to": [1, 15, 16],
			"faces": {
				"north": {"uv": [0, 1, 1, 15], "texture": "#0"},
				"east": {"uv": [0, 1, 1, 15], "texture": "#0"},
				"south": {"uv": [0, 1, 1, 15], "texture": "#0"},
				"west": {"uv": [0, 1, 1, 15], "texture": "#0"}
			}
		},
		{
			"from": [0, 1, 0],
			"to": [1, 15, 1],
			"faces": {
				"north": {"uv": [0, 1, 1, 15], "texture": "#0"},
				"east": {"uv": [0, 1, 1, 15], "texture": "#0"},
				"south": {"uv": [0, 1, 1, 15], "texture": "#0"},
				"west": {"uv": [0, 1, 1, 15], "texture": "#0"}
			}
		},
		{
			"from": [15, 1, 15],
			"to": [16, 15, 16],
			"faces": {
				"north": {"uv": [0, 1, 1, 15], "texture": "#0"},
				"east": {"uv": [0, 1, 1, 15], "texture": "#0"},
				"south": {"uv": [0, 1, 1, 15], "texture": "#0"},
				"west": {"uv": [0, 1, 1, 15], "texture": "#0"}
			}
		},
		{
			"from": [15, 1, 0],
			"to": [16, 15, 1],
			"faces": {
				"north": {"uv": [0, 1, 1, 15], "texture": "#0"},
				"east": {"uv": [0, 1, 1, 15], "texture": "#0"},
				"south": {"uv": [0, 1, 1, 15], "texture": "#0"},
				"west": {"uv": [0, 1, 1, 15], "texture": "#0"}
			}
		},
		{
			"from": [1, 1, 0],
			"to": [15, 15, 1],
			"faces": {
				"north": {"uv": [1, 1, 15, 15], "texture": "#1"},
				"south": {"uv": [1, 1, 15, 15], "texture": "#1"}
			}
		},
		{
			"from": [1, 1, 15],
			"to": [15, 15, 16],
			"faces": {
				"north": {"uv": [1, 1, 15, 15], "texture": "#1"},
				"south": {"uv": [1, 1, 15, 15], "texture": "#1"}
			}
		},
		{
			"from": [0, 1, 1],
			"to": [1, 15, 15],
			"faces": {
				"east": {"uv": [1, 1, 15, 15], "texture": "#1"},
				"west": {"uv": [1, 1, 15, 15], "texture": "#1"}
			}
		},
		{
			"from": [15, 1, 1],
			"to": [16, 15, 15],
			"faces": {
				"east": {"uv": [1, 1, 15, 15], "texture": "#1"},
				"west": {"uv": [1, 1, 15, 15], "texture": "#1"}
			}
		}
	]
}

 

if i place the block in the air or near the glass there's no problem, your shape work but as you said it isn't the solution, anyway thanks for the starting point 😃

Link to comment
Share on other sites

Like I said above I am no expert on the lighting, but this is my understanding of why it works.

 

What my example does is create holes in the sides of the block and I have also used this as the collision shape.

This lets the lighting engine allow light from the side.

 

I don't know if this is good for you, e.g. it would also let chickens walk through your block - at least at size of the slices I defined. 🙂

 

Unless somebody knows a different way you will probably have to draw the block yourself by turning the block into a BlockEntity and using a BlockEntityRenderer.

Your real issue I think is the json models don't really let you define one part of the block transparent like glass and other parts solid, at least not with internal faces?

 

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
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.

 Share



×
×
  • Create New...

Important Information

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