-
-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1.20-new' into 1.20-new-sodium
- Loading branch information
Showing
32 changed files
with
491 additions
and
74 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/main/java/net/coderbot/iris/layer/InnerWrappedRenderType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package net.coderbot.iris.layer; | ||
|
||
import net.coderbot.batchedentityrendering.impl.BlendingStateHolder; | ||
import net.coderbot.batchedentityrendering.impl.TransparencyType; | ||
import net.coderbot.batchedentityrendering.impl.WrappableRenderType; | ||
import net.coderbot.iris.mixin.rendertype.RenderTypeAccessor; | ||
import net.minecraft.client.renderer.RenderStateShard; | ||
import net.minecraft.client.renderer.RenderType; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
public class InnerWrappedRenderType extends RenderType implements WrappableRenderType, BlendingStateHolder { | ||
private final RenderStateShard extra; | ||
private final RenderType wrapped; | ||
|
||
public InnerWrappedRenderType(String name, RenderType wrapped, RenderStateShard extra) { | ||
super(name, wrapped.format(), wrapped.mode(), wrapped.bufferSize(), | ||
wrapped.affectsCrumbling(), shouldSortOnUpload(wrapped), wrapped::setupRenderState, wrapped::clearRenderState); | ||
|
||
this.extra = extra; | ||
this.wrapped = wrapped; | ||
} | ||
|
||
public static InnerWrappedRenderType wrapExactlyOnce(String name, RenderType wrapped, RenderStateShard extra) { | ||
if (wrapped instanceof InnerWrappedRenderType) { | ||
wrapped = ((InnerWrappedRenderType) wrapped).unwrap(); | ||
} | ||
|
||
return new InnerWrappedRenderType(name, wrapped, extra); | ||
} | ||
|
||
@Override | ||
public void setupRenderState() { | ||
super.setupRenderState(); | ||
|
||
extra.setupRenderState(); | ||
} | ||
|
||
@Override | ||
public void clearRenderState() { | ||
extra.clearRenderState(); | ||
|
||
super.clearRenderState(); | ||
} | ||
|
||
@Override | ||
public RenderType unwrap() { | ||
return this.wrapped; | ||
} | ||
|
||
@Override | ||
public Optional<RenderType> outline() { | ||
return this.wrapped.outline(); | ||
} | ||
|
||
@Override | ||
public boolean isOutline() { | ||
return this.wrapped.isOutline(); | ||
} | ||
|
||
@Override | ||
public boolean equals(@Nullable Object object) { | ||
if (object == null) { | ||
return false; | ||
} | ||
|
||
if (object.getClass() != this.getClass()) { | ||
return false; | ||
} | ||
|
||
InnerWrappedRenderType other = (InnerWrappedRenderType) object; | ||
|
||
return Objects.equals(this.wrapped, other.wrapped) && Objects.equals(this.extra, other.extra); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
// Add two so that we don't have the exact same hash as the wrapped object. | ||
// This means that we won't have a guaranteed collision if we're inserted to a map alongside the unwrapped object. | ||
return this.wrapped.hashCode() + 2; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "iris_wrapped:" + this.wrapped.toString(); | ||
} | ||
|
||
private static boolean shouldSortOnUpload(RenderType type) { | ||
return ((RenderTypeAccessor) type).shouldSortOnUpload(); | ||
} | ||
|
||
@Override | ||
public TransparencyType getTransparencyType() { | ||
return ((BlendingStateHolder) wrapped).getTransparencyType(); | ||
} | ||
|
||
@Override | ||
public void setTransparencyType(TransparencyType transparencyType) { | ||
((BlendingStateHolder) wrapped).setTransparencyType(transparencyType); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/net/coderbot/iris/layer/LightningRenderStateShard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.coderbot.iris.layer; | ||
|
||
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.RenderStateShard; | ||
|
||
public class LightningRenderStateShard extends RenderStateShard { | ||
public static final LightningRenderStateShard INSTANCE = new LightningRenderStateShard(); | ||
private static int backupValue = 0; | ||
|
||
private static final NamespacedId LIGHT = new NamespacedId("minecraft", "lightning_bolt"); | ||
|
||
public LightningRenderStateShard() { | ||
super("iris:lightning", () -> { | ||
if (BlockRenderingSettings.INSTANCE.getEntityIds() != null) { | ||
backupValue = CapturedRenderingState.INSTANCE.getCurrentRenderedEntity(); | ||
CapturedRenderingState.INSTANCE.setCurrentEntity(BlockRenderingSettings.INSTANCE.getEntityIds().applyAsInt(LIGHT)); | ||
GbufferPrograms.runFallbackEntityListener(); | ||
} | ||
}, () -> { | ||
if (BlockRenderingSettings.INSTANCE.getEntityIds() != null) { | ||
CapturedRenderingState.INSTANCE.setCurrentEntity(backupValue); | ||
backupValue = 0; | ||
GbufferPrograms.runFallbackEntityListener(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/net/coderbot/iris/mixin/MixinLightningBoltRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package net.coderbot.iris.mixin; | ||
|
||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import net.coderbot.iris.pipeline.LightningHandler; | ||
import net.minecraft.client.renderer.LightTexture; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.entity.LightningBoltRenderer; | ||
import net.minecraft.client.renderer.texture.OverlayTexture; | ||
import net.minecraft.resources.ResourceLocation; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(LightningBoltRenderer.class) | ||
public class MixinLightningBoltRenderer { | ||
@Redirect(method = "render(Lnet/minecraft/world/entity/LightningBolt;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderType;lightning()Lnet/minecraft/client/renderer/RenderType;")) | ||
private RenderType iris$overrideTex() { | ||
return LightningHandler.IRIS_LIGHTNING; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/net/coderbot/iris/pipeline/LightningHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.coderbot.iris.pipeline; | ||
|
||
import com.mojang.blaze3d.vertex.DefaultVertexFormat; | ||
import com.mojang.blaze3d.vertex.VertexFormat; | ||
import net.coderbot.iris.layer.InnerWrappedRenderType; | ||
import net.coderbot.iris.layer.LightningRenderStateShard; | ||
import net.coderbot.iris.layer.OuterWrappedRenderType; | ||
import net.minecraft.client.renderer.RenderType; | ||
|
||
public class LightningHandler extends RenderType { | ||
public static final RenderType IRIS_LIGHTNING = new InnerWrappedRenderType("iris_lightning2", RenderType.create( | ||
"iris_lightning", | ||
DefaultVertexFormat.POSITION_COLOR, | ||
VertexFormat.Mode.QUADS, | ||
256, | ||
false, | ||
true, | ||
RenderType.CompositeState.builder() | ||
.setShaderState(RENDERTYPE_LIGHTNING_SHADER) | ||
.setWriteMaskState(COLOR_DEPTH_WRITE) | ||
.setTransparencyState(LIGHTNING_TRANSPARENCY) | ||
.setOutputState(WEATHER_TARGET) | ||
.createCompositeState(false) | ||
), new LightningRenderStateShard()); | ||
|
||
public LightningHandler(String pRenderType0, VertexFormat pVertexFormat1, VertexFormat.Mode pVertexFormat$Mode2, int pInt3, boolean pBoolean4, boolean pBoolean5, Runnable pRunnable6, Runnable pRunnable7) { | ||
super(pRenderType0, pVertexFormat1, pVertexFormat$Mode2, pInt3, pBoolean4, pBoolean5, pRunnable6, pRunnable7); | ||
} | ||
} |
Oops, something went wrong.