Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Dec 4, 2024
1 parent 61c7bf1 commit d9397e2
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 37 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {
id("fabric-loom") version("1.8.10") apply(false)
}

val MINECRAFT_VERSION by extra { "1.21.4-rc3" }
val NEOFORGE_VERSION by extra { "21.3.9-beta" }
val MINECRAFT_VERSION by extra { "1.21.4" }
val NEOFORGE_VERSION by extra { "21.4.0-beta" }
val FABRIC_LOADER_VERSION by extra { "0.16.9" }
val FABRIC_API_VERSION by extra { "0.110.5+1.21.4" }

Expand All @@ -14,7 +14,7 @@ val FABRIC_API_VERSION by extra { "0.110.5+1.21.4" }
val PARCHMENT_VERSION by extra { null }

// https://semver.org/
val MOD_VERSION by extra { "1.8.1" }
val MOD_VERSION by extra { "1.8.2" }

allprojects {
apply(plugin = "java")
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ dependencies {

modCompileOnly("net.fabricmc.fabric-api:fabric-renderer-api-v1:3.2.9+1172e897d7")

modImplementation(files(rootDir.resolve("custom_sodium").resolve("sodium-fabric-0.6.0-snapshot+mc1.21.4-rc3-local.jar")))
modImplementation("maven.modrinth", "sodium", "mc1.21.4-0.6.2-fabric")
modCompileOnly("org.antlr:antlr4-runtime:4.13.1")
modCompileOnly("io.github.douira:glsl-transformer:2.0.1")
modCompileOnly("org.anarres:jcpp:1.4.14")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.MultiBufferSource;
Expand All @@ -15,16 +16,17 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(WeatherEffectRenderer.class)
public class MixinWeatherRenderer {
@ModifyArg(method = "render(Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/world/phys/Vec3;IFLjava/util/List;Ljava/util/List;)V", index = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderType;weather(Lnet/minecraft/resources/ResourceLocation;Z)Lnet/minecraft/client/renderer/RenderType;", remap = false))
private boolean iris$writeRainAndSnowToDepthBuffer(boolean depthMaskEnabled) {
@Redirect(method = "render(Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/world/phys/Vec3;IFLjava/util/List;Ljava/util/List;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;useShaderTransparency()Z"))
private boolean iris$writeRainAndSnowToDepthBuffer() {
if (Iris.getPipelineManager().getPipeline().map(WorldRenderingPipeline::shouldWriteRainAndSnowToDepthBuffer).orElse(false)) {
return true;
}

return depthMaskEnabled;
return Minecraft.useShaderTransparency();
}

@WrapMethod(method = "render(Lnet/minecraft/world/level/Level;Lnet/minecraft/client/renderer/MultiBufferSource;IFLnet/minecraft/world/phys/Vec3;)V")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.SolidBucketItem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -29,7 +29,7 @@ public class ItemStackStateLayerMixin {
@Inject(method = "render", at = @At("HEAD"))
private void onRender(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j, CallbackInfo ci, @Share("lastBState") LocalIntRef ref) {
ref.set(CapturedRenderingState.INSTANCE.getCurrentRenderedBlockEntity());
iris$setupId(((ItemContextState) parentState).getDisplayStack());
iris$setupId(((ItemContextState) parentState).getDisplayItem());
}

@Inject(method = "render", at = @At("TAIL"))
Expand All @@ -39,18 +39,18 @@ private void onRenderEnd(PoseStack poseStack, MultiBufferSource multiBufferSourc
}

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

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

CapturedRenderingState.INSTANCE.setCurrentBlockEntity(1);

//System.out.println(WorldRenderingSettings.INSTANCE.getBlockStateIds().getInt(blockItem.getBlock().defaultBlockState()));
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(WorldRenderingSettings.INSTANCE.getBlockStateIds().getOrDefault(blockItem.getBlock().defaultBlockState(), 0));
} else {
ResourceLocation location = BuiltInRegistries.ITEM.getKey(pItemRenderer0.getItem());
ResourceLocation location = BuiltInRegistries.ITEM.getKey(item);

CapturedRenderingState.INSTANCE.setCurrentRenderedItem(WorldRenderingSettings.INSTANCE.getItemIds().applyAsInt(new NamespacedId(location.getNamespace(), location.getPath())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.irisshaders.iris.mixinterface.ItemContextState;
import net.minecraft.client.renderer.item.ItemStackRenderState;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
Expand All @@ -12,15 +13,15 @@
@Mixin(ItemStackRenderState.class)
public class ItemStackStateMixin implements ItemContextState {
@Unique
private ItemStack iris_displayStack;
private Item iris_displayStack;

@Override
public void setDisplayStack(ItemStack itemStack) {
public void setDisplayItem(Item itemStack) {
this.iris_displayStack = itemStack;
}

@Override
public ItemStack getDisplayStack() {
public Item getDisplayItem() {
return iris_displayStack;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
package net.irisshaders.iris.mixin.entity_render_context;

import com.mojang.blaze3d.vertex.PoseStack;
import net.irisshaders.iris.mixinterface.ItemContextState;
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
import net.irisshaders.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.renderer.item.ItemModelResolver;
import net.minecraft.client.renderer.item.ItemStackRenderState;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SolidBucketItem;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
Expand All @@ -32,6 +20,6 @@ public abstract class MixinItemRenderer {

@Inject(method = "appendItemLayers", at = @At(value = "HEAD"))
private void changeId(ItemStackRenderState itemStackRenderState, ItemStack itemStack, ItemDisplayContext itemDisplayContext, Level level, LivingEntity livingEntity, int i, CallbackInfo ci) {
((ItemContextState) itemStackRenderState).setDisplayStack(itemStack);
((ItemContextState) itemStackRenderState).setDisplayItem(itemStack != null ? itemStack.getItem() : null);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package net.irisshaders.iris.mixinterface;

import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

public interface ItemContextState {
void setDisplayStack(ItemStack itemStack);
void setDisplayItem(Item itemStack);

ItemStack getDisplayStack();
Item getDisplayItem();
}
2 changes: 1 addition & 1 deletion fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ dependencies {
addRuntimeFabricModule("fabric-rendering-fluids-v1")
addRuntimeFabricModule("fabric-resource-loader-v0")

modImplementation(files(rootDir.resolve("custom_sodium").resolve("sodium-fabric-0.6.0-snapshot+mc1.21.4-rc3-local.jar")))
modImplementation("maven.modrinth", "sodium", "mc1.21.4-0.6.2-fabric")
implementAndInclude("org.antlr:antlr4-runtime:4.13.1")
implementAndInclude("io.github.douira:glsl-transformer:2.0.1")
implementAndInclude("org.anarres:jcpp:1.4.14")
Expand Down
2 changes: 1 addition & 1 deletion neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ dependencies {
runtimeOnly("org.sinytra.forgified-fabric-api:fabric-rendering-data-attachment-v1:0.3.48+73761d2e19")
runtimeOnly("org.sinytra.forgified-fabric-api:fabric-block-view-api-v2:1.0.10+9afaaf8c19")

implementation("maven.modrinth", "sodium", "mc1.21.3-0.6.1-neoforge")
implementation("maven.modrinth", "sodium", "mc1.21.4-0.6.2-neoforge")
includeAdditional("io.github.douira:glsl-transformer:2.0.1")
includeAdditional("org.anarres:jcpp:1.4.14")
includeAdditional("org.antlr:antlr4-runtime:4.13.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public abstract class MixinLevelRenderer {
@Shadow
public abstract Frustum getFrustum();

@WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleEngine;render(Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;FLnet/minecraft/client/renderer/culling/Frustum;Ljava/util/function/Predicate;)V", ordinal = 1))
private void redirectSolidParticles(ParticleEngine instance, LightTexture lightTexture, Camera camera, float v, Frustum frustum, Predicate<ParticleRenderType> predicate, Operation<Void> original) {
@WrapOperation(method = "lambda$addMainPass$2", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleEngine;render(Lnet/minecraft/client/Camera;FLnet/minecraft/client/renderer/MultiBufferSource$BufferSource;Lnet/minecraft/client/renderer/culling/Frustum;Ljava/util/function/Predicate;)V"))
private void redirectSolidParticles(ParticleEngine instance, Camera camera, float v, MultiBufferSource.BufferSource bufferSource, Frustum frustum, Predicate<ParticleRenderType> predicate, Operation<Void> original) {
ParticleRenderingSettings settings = getRenderingSettings();

Predicate<ParticleRenderType> newPredicate = predicate;
Expand All @@ -62,10 +62,10 @@ private void redirectSolidParticles(ParticleEngine instance, LightTexture lightT
return;
}

original.call(instance, lightTexture, camera, v, frustum, newPredicate);
original.call(instance, camera, v, bufferSource, frustum, newPredicate);
}

@WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleEngine;render(Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;FLnet/minecraft/client/renderer/culling/Frustum;Ljava/util/function/Predicate;)V", ordinal = 2))
@WrapOperation(method = "lambda$addParticlesPass$3", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleEngine;render(Lnet/minecraft/client/Camera;FLnet/minecraft/client/renderer/MultiBufferSource$BufferSource;Lnet/minecraft/client/renderer/culling/Frustum;Ljava/util/function/Predicate;)V"))
private void redirectTransParticles(ParticleEngine instance, LightTexture lightTexture, Camera camera, float v, Frustum frustum, Predicate<ParticleRenderType> predicate, Operation<Void> original) {
ParticleRenderingSettings settings = getRenderingSettings();

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pluginManagement {
}
}

include("common", "fabric")
include("common", "fabric", "neoforge")

0 comments on commit d9397e2

Please sign in to comment.