Skip to content

Commit

Permalink
Merge branch '1.18.2t' into 1.19.1
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Sep 7, 2023
2 parents 0e23d6a + b8de6a5 commit 56105d1
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package net.coderbot.iris.mixin.entity_render_context;

import com.mojang.blaze3d.vertex.PoseStack;
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
import net.coderbot.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.layers.CapeLayer;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(CapeLayer.class)
public class MixinCapeLayer {
private static final NamespacedId CAPE_LOCATION = new NamespacedId("minecraft", "player_cape");

@Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/player/AbstractClientPlayer;FFFFFF)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;pushPose()V"), locals = LocalCapture.CAPTURE_FAILHARD)
private void changeId(PoseStack pCapeLayer0, MultiBufferSource pMultiBufferSource1, int pInt2, AbstractClientPlayer pAbstractClientPlayer3, float pFloat4, float pFloat5, float pFloat6, float pFloat7, float pFloat8, float pFloat9, CallbackInfo ci, ItemStack lvItemStack11) {
if (BlockRenderingSettings.INSTANCE.getItemIds() == null) return;

CapturedRenderingState.INSTANCE.setCurrentRenderedItem(BlockRenderingSettings.INSTANCE.getItemIds().applyAsInt(CAPE_LOCATION));
}

@Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/player/AbstractClientPlayer;FFFFFF)V", at = @At(value = "RETURN"))
private void changeId2(CallbackInfo ci) {
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package net.coderbot.iris.mixin.entity_render_context;

import com.mojang.blaze3d.vertex.PoseStack;
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
import net.coderbot.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.entity.layers.ElytraLayer;
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.PlayerModelPart;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(ElytraLayer.class)
public abstract class MixinElytraLayer<T extends LivingEntity, M extends EntityModel<T>> extends RenderLayer<T, M> {
@Unique
private static final NamespacedId ELYTRA_CAPE_LOCATION = new NamespacedId("minecraft", "elytra_with_cape");

public MixinElytraLayer(RenderLayerParent<T, M> pRenderLayer0) {
super(pRenderLayer0);
}

@Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/world/entity/LivingEntity;FFFFFF)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;pushPose()V"), locals = LocalCapture.CAPTURE_FAILHARD)
private void changeId(PoseStack pElytraLayer0, MultiBufferSource pMultiBufferSource1, int pInt2, T pLivingEntity3, float pFloat4, float pFloat5, float pFloat6, float pFloat7, float pFloat8, float pFloat9, CallbackInfo ci, ItemStack lvItemStack11, ResourceLocation lvResourceLocation12) {
if (BlockRenderingSettings.INSTANCE.getItemIds() == null) return;

if (pLivingEntity3 instanceof AbstractClientPlayer player && player.isCapeLoaded()
&& player.getCloakTextureLocation() != null
&& player.isModelPartShown(PlayerModelPart.CAPE)) {
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(BlockRenderingSettings.INSTANCE.getItemIds().applyAsInt(ELYTRA_CAPE_LOCATION));
return;
}

ResourceLocation location = Registry.ITEM.getKey(Items.ELYTRA);

CapturedRenderingState.INSTANCE.setCurrentRenderedItem(BlockRenderingSettings.INSTANCE.getItemIds().applyAsInt(new NamespacedId(location.getNamespace(), location.getPath())));
}

@Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/world/entity/LivingEntity;FFFFFF)V", at = @At(value = "RETURN"))
private void changeId2(CallbackInfo ci) {
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ public class MixinEntityRenderDispatcher {
PoseStack poseStack, MultiBufferSource bufferSource, int light,
CallbackInfo ci) {
CapturedRenderingState.INSTANCE.setCurrentEntity(0);
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package net.coderbot.iris.mixin.entity_render_context;

import com.mojang.blaze3d.vertex.PoseStack;
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
import net.coderbot.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.entity.layers.HorseArmorLayer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.animal.horse.Horse;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.HorseArmorItem;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(HorseArmorLayer.class)
public class MixinHorseArmorLayer {
@Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/world/entity/animal/horse/Horse;FFFFFF)V", at = @At(value = "HEAD"))
private void changeId(PoseStack pHorseArmorLayer0, MultiBufferSource pMultiBufferSource1, int pInt2, Horse pHorse3, float pFloat4, float pFloat5, float pFloat6, float pFloat7, float pFloat8, float pFloat9, CallbackInfo ci) {
if (BlockRenderingSettings.INSTANCE.getItemIds() == null || !(pHorse3.getArmor().getItem() instanceof HorseArmorItem)) return;

ResourceLocation location = Registry.ITEM.getKey((pHorse3.getArmor().getItem()));
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(BlockRenderingSettings.INSTANCE.getItemIds().applyAsInt(new NamespacedId(location.getNamespace(), location.getPath())));
}

@Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/world/entity/animal/horse/Horse;FFFFFF)V", at = @At(value = "TAIL"))
private void changeId2(CallbackInfo ci) {
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.*;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -26,11 +24,22 @@ public abstract class MixinItemRenderer {
@Unique
private int previousBeValue;

@Inject(method = "render", at = @At(value = "HEAD"))
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemBlockRenderTypes;getRenderType(Lnet/minecraft/world/item/ItemStack;Z)Lnet/minecraft/client/renderer/RenderType;"))
private void changeId(ItemStack pItemRenderer0, ItemTransforms.TransformType pItemTransforms$TransformType1, boolean pBoolean2, PoseStack pPoseStack3, MultiBufferSource pMultiBufferSource4, int pInt5, int pInt6, BakedModel pBakedModel7, CallbackInfo ci) {
iris$setupId(pItemRenderer0);
}

// Attempt Indium support
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/BlockEntityWithoutLevelRenderer;renderByItem(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/client/renderer/block/model/ItemTransforms$TransformType;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;II)V"))
private void changeId2(ItemStack pItemRenderer0, ItemTransforms.TransformType pItemTransforms$TransformType1, boolean pBoolean2, PoseStack pPoseStack3, MultiBufferSource pMultiBufferSource4, int pInt5, int pInt6, BakedModel pBakedModel7, CallbackInfo ci) {
iris$setupId(pItemRenderer0);
}

@Unique
private void iris$setupId(ItemStack pItemRenderer0) {
if (BlockRenderingSettings.INSTANCE.getItemIds() == null) return;

if (pItemRenderer0.getItem() instanceof BlockItem blockItem) {
if (pItemRenderer0.getItem() instanceof BlockItem blockItem && !(pItemRenderer0.getItem() instanceof SolidBucketItem)) {
if (BlockRenderingSettings.INSTANCE.getBlockStateIds() == null) return;

previousBeValue = CapturedRenderingState.INSTANCE.getCurrentRenderedBlockEntity();
Expand All @@ -44,7 +53,7 @@ private void changeId(ItemStack pItemRenderer0, ItemTransforms.TransformType pIt
}
}

@Inject(method = "render", at = @At(value = "TAIL"))
@Inject(method = "render", at = @At(value = "RETURN"))
private void changeId2(CallbackInfo ci) {
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
CapturedRenderingState.INSTANCE.setCurrentBlockEntity(previousBeValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ public static void addWorldInfoUniforms(UniformHolder uniforms) {
return 0;
}
});
uniforms.uniform1f(UniformUpdateFrequency.PER_FRAME, "cloudHeight", () -> {
if (level != null) {
return level.effects().getCloudHeight();
} else {
return 192.0;
}
});

uniforms.uniform1i(UniformUpdateFrequency.PER_FRAME, "heightLimit", () -> {
if (level != null) {
return level.dimensionType().height();
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/mixins.iris.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@
"MixinUniform",
"MixinVertexBuffer",
"entity_render_context.MixinBlockEntityRenderDispatcher",
"entity_render_context.MixinCapeLayer",
"entity_render_context.MixinElytraLayer",
"entity_render_context.MixinEntityRenderDispatcher",
"entity_render_context.MixinHorseArmorLayer",
"entity_render_context.MixinHumanoidArmorLayer",
"entity_render_context.MixinItemRenderer",
"fabulous.MixinDisableFabulousGraphics",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import me.jellysquid.mods.sodium.client.render.pipeline.context.ChunkRenderCacheLocal;
import me.jellysquid.mods.sodium.client.util.task.CancellationSource;
import me.jellysquid.mods.sodium.client.world.WorldSlice;
import net.coderbot.iris.Iris;
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
import net.coderbot.iris.compat.sodium.impl.block_context.ChunkBuildBuffersExt;
import net.coderbot.iris.vertices.ExtendedDataHelper;
Expand All @@ -23,11 +22,9 @@
import net.minecraft.world.level.block.LightBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

Expand Down Expand Up @@ -79,28 +76,36 @@ public class MixinChunkRenderRebuildTask {
}
}

@Redirect(method = "performBuild", at = @At(value = "INVOKE",
@Inject(method = "performBuild", at = @At(value = "INVOKE",
target = "net/minecraft/client/renderer/ItemBlockRenderTypes.getChunkRenderType(" +
"Lnet/minecraft/world/level/block/state/BlockState;" +
")Lnet/minecraft/client/renderer/RenderType;"))
private RenderType iris$wrapGetBlockLayer(BlockState blockState, ChunkBuildContext context) {
")Lnet/minecraft/client/renderer/RenderType;"), locals = LocalCapture.CAPTURE_FAILHARD)
private void iris$wrapGetBlockLayer(ChunkBuildContext context,
CancellationSource cancellationSource, CallbackInfoReturnable<ChunkBuildResult> cir,
ChunkRenderData.Builder renderData, VisGraph occluder, ChunkRenderBounds.Builder bounds, ChunkBuildBuffers buffers,
ChunkRenderCacheLocal cacheLocal,
WorldSlice slice, int baseX, int baseY, int baseZ, int maxX, int maxY, int maxZ,
BlockPos.MutableBlockPos pos, BlockPos.MutableBlockPos renderOffset,
int relY, int relZ, int relX, BlockState blockState) {
if (context.buffers instanceof ChunkBuildBuffersExt) {
((ChunkBuildBuffersExt) context.buffers).iris$setMaterialId(blockState, ExtendedDataHelper.BLOCK_RENDER_TYPE);
}

return ItemBlockRenderTypes.getChunkRenderType(blockState);
}

@Redirect(method = "performBuild", at = @At(value = "INVOKE",
@Inject(method = "performBuild", at = @At(value = "INVOKE",
target = "net/minecraft/client/renderer/ItemBlockRenderTypes.getRenderLayer(" +
"Lnet/minecraft/world/level/material/FluidState;" +
")Lnet/minecraft/client/renderer/RenderType;"))
private RenderType iris$wrapGetFluidLayer(FluidState fluidState, ChunkBuildContext context) {
")Lnet/minecraft/client/renderer/RenderType;"), locals = LocalCapture.CAPTURE_FAILHARD)
private void iris$wrapGetFluidLayer(ChunkBuildContext context,
CancellationSource cancellationSource, CallbackInfoReturnable<ChunkBuildResult> cir,
ChunkRenderData.Builder renderData, VisGraph occluder, ChunkRenderBounds.Builder bounds, ChunkBuildBuffers buffers,
ChunkRenderCacheLocal cacheLocal,
WorldSlice slice, int baseX, int baseY, int baseZ, int maxX, int maxY, int maxZ,
BlockPos.MutableBlockPos pos, BlockPos.MutableBlockPos renderOffset,
int relY, int relZ, int relX, BlockState blockState, boolean rendered, FluidState fluidState) {
if (context.buffers instanceof ChunkBuildBuffersExt) {
((ChunkBuildBuffersExt) context.buffers).iris$setMaterialId(fluidState.createLegacyBlock(), ExtendedDataHelper.FLUID_RENDER_TYPE);
}

return ItemBlockRenderTypes.getRenderLayer(fluidState);
}

@Inject(method = "performBuild",
Expand Down

0 comments on commit 56105d1

Please sign in to comment.