Can't retrieve entity data when render() is called in BlockEntityRenderer
Onionus007 opened this issue ยท 6 comments
So basically what I am trying to do is render an item which is contained in the Inventory which is held by the BlockEntity attached to the block, I can place items and take them out just fine, but no matter what when render() is called from ReplicatorBlockEntityRenderer, it's like the entity
variable is empty, what is wrong with this? P.S. Rendering a preset block works just fine
public class ReplicatorBlockEntityRenderer implements BlockEntityRenderer<ReplicatorBlockEntity> {
public ReplicatorBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) {
}
@Environment(EnvType.CLIENT)
@Override
public void render(ReplicatorBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
matrices.push();
matrices.translate(.5, .55, .5);
ItemRenderer renderer = MinecraftClient.getInstance().getItemRenderer();
ItemStack stack = entity.getStack(0);
renderer.renderItem(stack, ModelTransformation.Mode.GROUND, light, overlay, matrices, vertexConsumers, 0);
matrices.pop();
}
}
And yes, my block is transparent in case you are wondering why I translate the object to be inside the block, think of this as a glorified display stand
Guess mode enabled
Since rendering is on the client, are you sending the block entity data to the client?
This is not the same thing as using Minecraft's inventory which only makes the inventory's stacks available to the container UI.
If you are doing this, are you invoking sync() on the server when the data changes?
@warjort Before I posted the issue I must admit I was not, but now I am even more confused, I am calling sync() every time the onUse() function is called, so technically it should be updated when an item is inserted or removed, but the problem now is that the entity is not updated when an item is removed
Before I posted the issue I must admit I was not, but now I am even more confused, I am calling sync() every time the onUse() function is called, so technically it should be updated when an item is inserted or removed, but the problem now is that the entity is not updated when an item is removed
Hard to help you if you don't post specifics.
But it sounds to me like you need to add some logging so you can see;
- when the syncs and onUse (for both the client and server) happen
- the data the server is sending to the client when the sync happens
- the data that arrives on the client and the after state once it is applied
From this you should be able to figure out where the logic is wrong in your code