#Modifying block entity rendering based on the player

97 messages · Page 1 of 1 (latest)

nimble ivy
#

I have this code which is intended to scale a block entities rendering to 0/0/0 (so make it disappear) if the player rendering it is crouching, the block just appears invisible always in the world, please help

lilac thistle
#

Does it render without it?

#

It being the if sneaking check

nimble ivy
#

Uhhhh

#

Lemme check

nimble ivy
#

Or the contents as well?

lilac thistle
#

Also one thing, idk but you never reset the value so outside the if set the scale to 1

#

Maybe

nimble ivy
lilac thistle
#

All good

nimble ivy
#

It was working a second ago without the contents

#

So I’m just bringing it back a sec

lilac thistle
#

Okay

lilac thistle
#

Can you send the text version of the code

#

Rq just so i can edit it

nimble ivy
#

yeah sure np

#

i reverted the changes to back when it was working and for some reason it isnt now

#

package net.doomxd.boe.block.entity.renderer;

import net.doomxd.boe.block.entity.custom.ElseBlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;

import java.awt.*;

public class ElseBlockEntityRenderer implements BlockEntityRenderer<ElseBlockEntity> {
public ElseBlockEntityRenderer(BlockEntityRendererFactory.Context context) {

}

@Override
public void render(ElseBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
    ClientPlayerEntity player =  MinecraftClient.getInstance().player;

}

private int getLightLevel(World world, BlockPos pos) {
    int bLight = world.getLightLevel(LightType.BLOCK, pos);
    int sLight = world.getLightLevel(LightType.SKY, pos);
    return LightmapTextureManager.pack(bLight, sLight);
}

}

lilac thistle
#

Let's see how this goes on a phone

nimble ivy
#

for some reason its rendering like this rn even tho i reset the code to what you see up there

lilac thistle
#
package net.doomxd.boe.block.entity.renderer;

import net.doomxd.boe.block.entity.custom.ElseBlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;

import java.awt.*;

public class ElseBlockEntityRenderer implements BlockEntityRenderer<ElseBlockEntity> {
    public ElseBlockEntityRenderer(BlockEntityRendererFactory.Context context) {

    }

    @Override
    public void render(ElseBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
        ClientPlayerEntity player =  MinecraftClient.getInstance().player;
matricies.push()
if(player.isSneaking() && player != null) {
matrices.scale(0,0,0)
} else {
matrices.scale(1,1,1)
}
matrices.pop()
    }

    private int getLightLevel(World world, BlockPos pos) {
        int bLight = world.getLightLevel(LightType.BLOCK, pos);
        int sLight = world.getLightLevel(LightType.SKY, pos);
        return LightmapTextureManager.pack(bLight, sLight);
    }
}
lilac thistle
nimble ivy
#

I see

lilac thistle
#

Sry bout the formatting, having to use my phone rn

nimble ivy
#

No worries, your help really means a lot even if your forgetting a couple semi colons lol

lilac thistle
#

Oop

#

Lmao

nimble ivy
#

Yeah I plugged it in, for some reason it’s still blank but since it was like that even when there was nothing in the render box I assume that means I did smth stupid elsewhere

#

I dunno why tho this was working fine an hour ago

lilac thistle
#

I honestly don't know of that is gonna work out not

#

Or*

#

I just might be sleep deprived lmao

nimble ivy
#

It’s alright lol

lilac thistle
#

What does the block do that requires an entity renderer

nimble ivy
#

I was trying to make it disappear and reappear based on the player viewing it and the people here said I need a block entity and a block entity renderer for it, I’m very new so I’m just following orders

lilac thistle
#

Ya that's what you need to do it

#

Can you show the model class?

nimble ivy
#

Uhhhh

#

Hold on lemme try to figure out which one that is

lilac thistle
#

Lmao

nimble ivy
#

omg

#

I think I might have found the perma invis issue

#

Lemme test rq

lilac thistle
#

... Did you not tell it to render...

nimble ivy
#

I told it to render as invisible, unless a boolean that was set to false by default was true while I was experimenting earlier

lilac thistle
#

Oh

nimble ivy
#

OK, so it’s not invisible anymore

#

I’m sorry, I’m stupid

lilac thistle
#

Does it work?

#

All good same here all the time

nimble ivy
#

No, sadly doesn’t seem to

#

Let me try one more time just in case

lilac thistle
#

Just look at me I put the name space of an old mod in one of my new mods by accident

#

And somehow moved where data gen outputs files

#

And made particles being registered stop data gen from working

#

So like... Ya I'm stupid to

nimble ivy
#

Oh lord

#

I mean I spent two hours trying to figure out why the block textures were purple and black

#

Only to realize I put them in the items folder

lilac thistle
#

😭

nimble ivy
#

Hell I didn’t even realize

#

A friend of mine did

#

It doesn’t seem like the scaling works sadly

surreal nexus
#

aw dang it

nimble ivy
#

I copy and pasted the whole thing over my file

surreal nexus
#

reeeeeeeeeeeeeeeeeeeeeeeeeeee

nimble ivy
#

I can try one more time just to double check. I didn’t do something stupid

#

Again

surreal nexus
#

i also love how you didnt notice i switched accounts

nimble ivy
#

You know I did realize the fault looked weird all of a sudden, but I thought I just missed it before

#

*faunt

#

*font

surreal nexus
#

lol

nimble ivy
#

So for the record all I’m doing when I copy and paste it in to change it is adding some semi colons, retyping the first matrices because it gets an error and flipping the if player is null and is sneaking because it tells me that it’s already too late to check for null if its second

#

I assume none of that could be the problem?

surreal nexus
#

i honestly have no idea just give me a few to get my brain to wake up again

nimble ivy
#

And just to be clear, I have basically no idea matracies actually does I just saw it in like four YouTube videos about item renders and on the documentation and I think it works how I’m using it here?

#

This is kind of just guess work tbh

surreal nexus
#

i belive so, also do you happen to know what the large oak tree is called file wise

nimble ivy
#

?

surreal nexus
#

like the big sprawling branch one?

nimble ivy
#

I don’t know sorry

surreal nexus
#

sigh all good

nimble ivy
#

I started learning fabric last week. I’m sorry. :(

surreal nexus
#

alll good just was checken bc ive been looking for like an hour

nimble ivy
#

So from what I can tell or at least guess

#

The commands are going through just it’s not targeted onto the actual block

#

I have absolutely no idea how to do that

#

I got to call it a night sadly, if you think of smth please lmk

surreal nexus
#

okay i will gn

nimble ivy
#

Gn

#

Also for anyone else who glances at this post: