Skip to content

Commit

Permalink
Merge branch 'refs/heads/1.20.3' into 1.20.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/net/irisshaders/iris/mixin/MixinLevelRenderer_SkipRendering.java
#	src/main/resources/fabric.mod.json
  • Loading branch information
IMS212 committed Jun 29, 2024
2 parents 0123249 + 8f668cf commit cdca0a2
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 18 deletions.
18 changes: 18 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ repositories {
includeGroup("maven.modrinth")
}
}
maven("https://maven.covers1624.net/")
}

plugins {
Expand All @@ -53,6 +54,21 @@ base {
}

loom {
runs {
create("clientWithQuickplay") {
client()
isIdeConfigGenerated = true
programArgs("--launch_target", "net.fabricmc.loader.impl.launch.knot.KnotClient")
mainClass.set("net.covers1624.devlogin.DevLogin")
projectDir.resolve("run").resolve("mods").resolve(Constants.MINECRAFT_VERSION).mkdirs()
vmArgs("-Dfabric.modsFolder=" + projectDir.resolve("run").resolve("mods").resolve(Constants.MINECRAFT_VERSION).absolutePath)
programArgs("--quickPlaySingleplayer", "World For " + Constants.MINECRAFT_VERSION)
if (Constants.ACTIVATE_RENDERDOC && DefaultNativePlatform.getCurrentOperatingSystem().isLinux) {
environmentVariable("LD_PRELOAD", "/usr/lib/librenderdoc.so")
}
}
}

mixin {
useLegacyMixinAp = false
}
Expand Down Expand Up @@ -134,6 +150,7 @@ dependencies {
minecraft(group = "com.mojang", name = "minecraft", version = Constants.MINECRAFT_VERSION)
mappings(loom.officialMojangMappings())
modImplementation(group = "net.fabricmc", name = "fabric-loader", version = Constants.FABRIC_LOADER_VERSION)
localRuntime("net.covers1624:DevLogin:0.1.0.5")

include("org.antlr:antlr4-runtime:4.13.1")
modImplementation("org.antlr:antlr4-runtime:4.13.1")
Expand Down Expand Up @@ -173,6 +190,7 @@ tasks {
environment("LD_PRELOAD", "/usr/lib/librenderdoc.so")
}
}

getByName<JavaCompile>("compileDesktopJava") {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@ private Iterable<Entity> skipRenderEntities(ClientLevel instance, Operation<Iter
}

@Redirect(method = "renderLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderChunksInFrustum:Lit/unimi/dsi/fastutil/objects/ObjectArrayList;"))
private ObjectArrayList<LevelRenderer.RenderChunkInfo> skipLocalBlockEntities(LevelRenderer instance) {
private ObjectArrayList<LevelRenderer.RenderChunkInfo> skipLocalBlockEntities(LevelRenderer instance, Operation<ObjectArrayList<SectionRenderDispatcher.RenderSection>> original) {
if (Iris.getPipelineManager().getPipelineNullable() instanceof IrisRenderingPipeline pipeline && pipeline.skipAllRendering()) {
return EMPTY_LIST;
} else {
return this.renderChunksInFrustum;
return original.call(instance);
}
}

@Redirect(method = "renderLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/LevelRenderer;globalBlockEntities:Ljava/util/Set;"))
private Set<BlockEntity> skipGlobalBlockEntities(LevelRenderer instance) {
@WrapOperation(method = "renderLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/LevelRenderer;globalBlockEntities:Ljava/util/Set;"))
private Set<BlockEntity> skipGlobalBlockEntities(LevelRenderer instance, Operation<Set<BlockEntity>> original) {
if (Iris.getPipelineManager().getPipelineNullable() instanceof IrisRenderingPipeline pipeline && pipeline.skipAllRendering()) {
return Collections.emptySet();
} else {
return this.globalBlockEntities;
return original.call(instance);
}
}
}
37 changes: 37 additions & 0 deletions src/main/java/net/irisshaders/iris/mixin/MixinQuickPlayDev.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package net.irisshaders.iris.mixin;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.DisconnectedScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.client.gui.screens.worldselection.SelectWorldScreen;
import net.minecraft.client.quickplay.QuickPlay;
import net.minecraft.world.Difficulty;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.LevelSettings;
import net.minecraft.world.level.WorldDataConfiguration;
import net.minecraft.world.level.levelgen.WorldOptions;
import net.minecraft.world.level.levelgen.presets.WorldPresets;
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;

@Mixin(QuickPlay.class)
public class MixinQuickPlayDev {
@Inject(method = "joinSingleplayerWorld", at = @At("HEAD"), cancellable = true)
private static void iris$createWorldIfDev(Minecraft minecraft, String string, CallbackInfo ci) {
if (FabricLoader.getInstance().isDevelopmentEnvironment()) {
ci.cancel();

if (!minecraft.getLevelSource().levelExists(string)) {
minecraft.createWorldOpenFlows().createFreshLevel(string, new LevelSettings(string, GameType.CREATIVE, false, Difficulty.HARD, true, new GameRules(), WorldDataConfiguration.DEFAULT),
WorldOptions.defaultWithRandomSeed(), WorldPresets::createNormalWorldDimensions, Minecraft.getInstance().screen);
} else {
minecraft.createWorldOpenFlows().checkForBackupAndLoad(string, () -> minecraft.setScreen(new TitleScreen()));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package net.irisshaders.iris.mixin.entity_render_context;

import com.mojang.blaze3d.vertex.PoseStack;
import it.unimi.dsi.fastutil.objects.Object2IntFunction;
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.entity.EntityRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
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(EntityRenderer.class)
public class MixinEntityRenderer<T extends Entity> {
@Unique
private static final NamespacedId NAME_TAG_ID = new NamespacedId("minecraft", "name_tag");

@Unique
private int lastId = -100;

@Inject(method = "renderNameTag", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getNameTagOffsetY()F"))
private void setNameTagId(T entity, Component component, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) {
Object2IntFunction<NamespacedId> entityIds = WorldRenderingSettings.INSTANCE.getEntityIds();

if (entityIds == null) {
return;
}

this.lastId = CapturedRenderingState.INSTANCE.getCurrentRenderedEntity();

int intId = entityIds.applyAsInt(NAME_TAG_ID);

CapturedRenderingState.INSTANCE.setCurrentEntity(intId);
}

@Inject(method = "renderNameTag", at = @At("RETURN"))
private void resetId(T entity, Component component, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) {
if (lastId != -100) {
CapturedRenderingState.INSTANCE.setCurrentEntity(lastId);
lastId = -100 ;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public abstract class MixinBufferBuilder extends DefaultedVertexConsumer impleme
@Unique
private boolean injectNormalAndUV1;
@Unique
private int vertexCount;
private int iris$vertexCount;
@Unique
private short currentBlock = -1;
@Unique
Expand Down Expand Up @@ -127,7 +127,7 @@ public abstract class MixinBufferBuilder extends DefaultedVertexConsumer impleme

@Inject(method = "reset()V", at = @At("HEAD"))
private void iris$onReset(CallbackInfo ci) {
vertexCount = 0;
iris$vertexCount = 0;
}

@Inject(method = "endVertex", at = @At("HEAD"))
Expand Down Expand Up @@ -171,16 +171,16 @@ public abstract class MixinBufferBuilder extends DefaultedVertexConsumer impleme
this.nextElement();
}

vertexCount++;
iris$vertexCount++;

if (mode == VertexFormat.Mode.QUADS && vertexCount == 4 || mode == VertexFormat.Mode.TRIANGLES && vertexCount == 3) {
fillExtendedData(vertexCount);
if (mode == VertexFormat.Mode.QUADS && iris$vertexCount == 4 || mode == VertexFormat.Mode.TRIANGLES && iris$vertexCount == 3) {
fillExtendedData(iris$vertexCount);
}
}

@Unique
private void fillExtendedData(int vertexAmount) {
vertexCount = 0;
iris$vertexCount = 0;

int stride = format.getVertexSize();

Expand Down Expand Up @@ -289,17 +289,17 @@ public void endBlock() {

@Override
public int iris$vertexCount() {
return vertexCount;
return iris$vertexCount;
}

@Override
public void iris$incrementVertexCount() {
vertexCount++;
iris$vertexCount++;
}

@Override
public void iris$resetVertexCount() {
vertexCount = 0;
iris$vertexCount = 0;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,9 @@ public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, It
}

private static void handleBooleanValue(String key, String value, BooleanConsumer handler) {
if ("true".equals(value)) {
if ("true".equals(value) || "1".equals(value)) {
handler.accept(true);
} else if ("false".equals(value)) {
} else if ("false".equals(value) || "0".equals(value)) {
handler.accept(false);
} else {
Iris.logger.warn("Unexpected value for boolean key " + key + " in shaders.properties: got " + value + ", but expected either true or false");
Expand All @@ -613,9 +613,9 @@ private static void handleBooleanDirective(String key, String value, String expe
return;
}

if ("true".equals(value)) {
if ("true".equals(value) || "1".equals(value)) {
handler.accept(OptionalBoolean.TRUE);
} else if ("false".equals(value)) {
} else if ("false".equals(value) || "0".equals(value)) {
handler.accept(OptionalBoolean.FALSE);
} else {
Iris.logger.warn("Unexpected value for boolean key " + key + " in shaders.properties: got " + value + ", but expected either true or false");
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/mixins.iris.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"MixinProgram",
"MixinProgramManager",
"MixinProgramType",
"MixinQuickPlayDev",
"MixinRenderSystem",
"MixinRenderTarget",
"MixinScreenEffectRenderer",
Expand All @@ -59,6 +60,7 @@
"entity_render_context.MixinElytraLayer",
"entity_render_context.MixinEnderDragonRenderer",
"entity_render_context.MixinEntityRenderDispatcher",
"entity_render_context.MixinEntityRenderer",
"entity_render_context.MixinHorseArmorLayer",
"entity_render_context.MixinHumanoidArmorLayer",
"entity_render_context.MixinItemRenderer",
Expand Down

0 comments on commit cdca0a2

Please sign in to comment.