Search in sources :

Example 1 with RenderStateShard

use of net.minecraft.client.renderer.RenderStateShard in project Iris by IrisShaders.

the class MixinBlockEntityRenderDispatcher method iris$beforeRender.

// I inject here in the method so that:
// 
// 1. we can know that some checks we need have already been done
// 2. if someone cancels this method hopefully it gets cancelled before this point
@Inject(method = "render", at = @At(value = "INVOKE", target = RUN_REPORTED))
private void iris$beforeRender(BlockEntity blockEntity, float tickDelta, PoseStack poseStack, MultiBufferSource bufferSource, CallbackInfo ci) {
    if (!(bufferSource instanceof WrappingMultiBufferSource)) {
        return;
    }
    Object2IntMap<BlockState> blockStateIds = BlockRenderingSettings.INSTANCE.getBlockStateIds();
    if (blockStateIds == null) {
        return;
    }
    // At this point, based on where we are in BlockEntityRenderDispatcher:
    // - The block entity is non-null
    // - The block entity has a world
    // - The block entity thinks that it's supported by a valid block
    int intId = blockStateIds.getOrDefault(blockEntity.getBlockState(), -1);
    RenderStateShard stateShard = BlockEntityRenderStateShard.forId(intId);
    ((WrappingMultiBufferSource) bufferSource).pushWrappingFunction(type -> new OuterWrappedRenderType("iris:is_block_entity", type, stateShard));
}
Also used : WrappingMultiBufferSource(net.coderbot.iris.fantastic.WrappingMultiBufferSource) BlockState(net.minecraft.world.level.block.state.BlockState) OuterWrappedRenderType(net.coderbot.iris.layer.OuterWrappedRenderType) RenderStateShard(net.minecraft.client.renderer.RenderStateShard) BlockEntityRenderStateShard(net.coderbot.iris.layer.BlockEntityRenderStateShard) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with RenderStateShard

use of net.minecraft.client.renderer.RenderStateShard in project Iris by IrisShaders.

the class MixinEntityRenderDispatcher method iris$beginEntityRender.

// Inject after MatrixStack#push to increase the chances that we won't be caught out by a poorly-positioned
// cancellation in an inject.
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;pushPose()V", shift = At.Shift.AFTER))
private void iris$beginEntityRender(Entity entity, double x, double y, double z, float yaw, float tickDelta, PoseStack poseStack, MultiBufferSource bufferSource, int light, CallbackInfo ci) {
    if (!(bufferSource instanceof WrappingMultiBufferSource)) {
        return;
    }
    ResourceLocation entityId = Registry.ENTITY_TYPE.getKey(entity.getType());
    Object2IntFunction<NamespacedId> entityIds = BlockRenderingSettings.INSTANCE.getEntityIds();
    if (entityIds == null) {
        return;
    }
    int intId = entityIds.applyAsInt(new NamespacedId(entityId.getNamespace(), entityId.getPath()));
    RenderStateShard phase = EntityRenderStateShard.forId(intId);
    ((WrappingMultiBufferSource) bufferSource).pushWrappingFunction(layer -> new OuterWrappedRenderType("iris:is_entity", layer, phase));
}
Also used : WrappingMultiBufferSource(net.coderbot.iris.fantastic.WrappingMultiBufferSource) NamespacedId(net.coderbot.iris.shaderpack.materialmap.NamespacedId) OuterWrappedRenderType(net.coderbot.iris.layer.OuterWrappedRenderType) RenderStateShard(net.minecraft.client.renderer.RenderStateShard) EntityRenderStateShard(net.coderbot.iris.layer.EntityRenderStateShard) ResourceLocation(net.minecraft.resources.ResourceLocation) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

WrappingMultiBufferSource (net.coderbot.iris.fantastic.WrappingMultiBufferSource)2 OuterWrappedRenderType (net.coderbot.iris.layer.OuterWrappedRenderType)2 RenderStateShard (net.minecraft.client.renderer.RenderStateShard)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 BlockEntityRenderStateShard (net.coderbot.iris.layer.BlockEntityRenderStateShard)1 EntityRenderStateShard (net.coderbot.iris.layer.EntityRenderStateShard)1 NamespacedId (net.coderbot.iris.shaderpack.materialmap.NamespacedId)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 BlockState (net.minecraft.world.level.block.state.BlockState)1