Skip to content

Commit

Permalink
Variable renames in the Iris fantastic package
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbot16 committed Sep 12, 2021
1 parent 2d0535c commit 6b7891d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureManager;

public class IrisParticleTextureSheets {
public static final ParticleRenderType OPAQUE_TERRAIN_SHEET = new ParticleRenderType() {
public class IrisParticleRenderTypes {
public static final ParticleRenderType OPAQUE_TERRAIN = new ParticleRenderType() {
public void begin(BufferBuilder bufferBuilder, TextureManager textureManager) {
RenderSystem.disableBlend();
RenderSystem.depthMask(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package net.coderbot.iris.fantastic;

public interface PhasedParticleManager {
public interface PhasedParticleEngine {
void setParticleRenderingPhase(ParticleRenderingPhase phase);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.coderbot.iris.mixin.fantastic;

import net.coderbot.iris.fantastic.IrisParticleTextureSheets;
import net.coderbot.iris.fantastic.IrisParticleRenderTypes;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.BarrierParticle;
import net.minecraft.client.particle.ParticleRenderType;
Expand Down Expand Up @@ -34,9 +34,9 @@ public class MixinBarrierParticle {
}

@Inject(method = "getRenderType", at = @At("HEAD"), cancellable = true)
private void iris$overrideParticleSheet(CallbackInfoReturnable<ParticleRenderType> cir) {
private void iris$overrideParticleRenderType(CallbackInfoReturnable<ParticleRenderType> cir) {
if (isOpaque) {
cir.setReturnValue(IrisParticleTextureSheets.OPAQUE_TERRAIN_SHEET);
cir.setReturnValue(IrisParticleRenderTypes.OPAQUE_TERRAIN);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
import net.coderbot.iris.fantastic.ParticleRenderingPhase;
import net.coderbot.iris.fantastic.PhasedParticleManager;
import net.coderbot.iris.fantastic.PhasedParticleEngine;
import net.coderbot.iris.layer.GbufferProgram;
import net.coderbot.iris.layer.GbufferPrograms;
import net.minecraft.client.Camera;
Expand Down Expand Up @@ -33,7 +33,7 @@ public class MixinLevelRenderer {

@Inject(method = "renderLevel", at = @At("HEAD"))
private void iris$resetParticleManagerPhase(PoseStack poseStack, float f, long l, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, CallbackInfo ci) {
((PhasedParticleManager) minecraft.particleEngine).setParticleRenderingPhase(ParticleRenderingPhase.EVERYTHING);
((PhasedParticleEngine) minecraft.particleEngine).setParticleRenderingPhase(ParticleRenderingPhase.EVERYTHING);
}

@Inject(method = "renderLevel", at = @At(value = "CONSTANT", args = "stringValue=entities"))
Expand All @@ -42,12 +42,12 @@ public class MixinLevelRenderer {

MultiBufferSource.BufferSource bufferSource = renderBuffers.bufferSource();

((PhasedParticleManager) minecraft.particleEngine).setParticleRenderingPhase(ParticleRenderingPhase.OPAQUE);
((PhasedParticleEngine) minecraft.particleEngine).setParticleRenderingPhase(ParticleRenderingPhase.OPAQUE);

GbufferPrograms.push(GbufferProgram.TEXTURED_LIT);
minecraft.particleEngine.render(poseStack, bufferSource, lightTexture, camera, f);
GbufferPrograms.pop(GbufferProgram.TEXTURED_LIT);

((PhasedParticleManager) minecraft.particleEngine).setParticleRenderingPhase(ParticleRenderingPhase.TRANSLUCENT);
((PhasedParticleEngine) minecraft.particleEngine).setParticleRenderingPhase(ParticleRenderingPhase.TRANSLUCENT);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package net.coderbot.iris.mixin.fantastic;

import com.google.common.collect.ImmutableList;
import net.coderbot.iris.fantastic.IrisParticleTextureSheets;
import net.coderbot.iris.fantastic.IrisParticleRenderTypes;
import net.coderbot.iris.fantastic.ParticleRenderingPhase;
import net.coderbot.iris.fantastic.PhasedParticleManager;
import net.coderbot.iris.fantastic.PhasedParticleEngine;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.client.particle.ParticleRenderType;
import org.spongepowered.asm.mixin.Final;
Expand All @@ -17,12 +17,12 @@
import java.util.List;

/**
* Extends the ParticleManager class to allow multiple phases of particle rendering.
* Extends the ParticleEngine class to allow multiple phases of particle rendering.
*
* This is used to enable the rendering of known-opaque particles much earlier than other particles, most notably before
* translucent content. Normally, particles behind translucent blocks are not visible on Fancy graphics, and a user must
* enable the much more intensive Fabulous graphics option. This is not ideal because Fabulous graphics is fundamentally
* incompatible with most shaderpacks.
* incompatible with most shader packs.
*
* So what causes this? Essentially, on Fancy graphics, all particles are rendered after translucent terrain. Aside from
* causing problems with particles being invisible, this also causes particles to write to the translucent depth buffer,
Expand All @@ -42,19 +42,19 @@
* As the saying goes, "Work smarter, not harder."
*/
@Mixin(ParticleEngine.class)
public class MixinParticleEngine implements PhasedParticleManager {
public class MixinParticleEngine implements PhasedParticleEngine {
@Unique
private ParticleRenderingPhase phase = ParticleRenderingPhase.EVERYTHING;

@Shadow
@Final
private static List<ParticleRenderType> RENDER_ORDER;

private static final List<ParticleRenderType> OPAQUE_PARTICLE_TEXTURE_SHEETS;
private static final List<ParticleRenderType> OPAQUE_PARTICLE_RENDER_TYPES;

static {
OPAQUE_PARTICLE_TEXTURE_SHEETS = ImmutableList.of(
IrisParticleTextureSheets.OPAQUE_TERRAIN_SHEET,
OPAQUE_PARTICLE_RENDER_TYPES = ImmutableList.of(
IrisParticleRenderTypes.OPAQUE_TERRAIN,
ParticleRenderType.PARTICLE_SHEET_OPAQUE,
ParticleRenderType.PARTICLE_SHEET_LIT,
ParticleRenderType.CUSTOM,
Expand All @@ -71,12 +71,12 @@ public class MixinParticleEngine implements PhasedParticleManager {
List<ParticleRenderType> toRender = new ArrayList<>(RENDER_ORDER);

// Remove all known opaque particle texture sheets.
toRender.removeAll(OPAQUE_PARTICLE_TEXTURE_SHEETS);
toRender.removeAll(OPAQUE_PARTICLE_RENDER_TYPES);

return toRender;
} else if (phase == ParticleRenderingPhase.OPAQUE) {
// Render only opaque particle sheets
return OPAQUE_PARTICLE_TEXTURE_SHEETS;
return OPAQUE_PARTICLE_RENDER_TYPES;
} else {
// Don't override particle rendering
return RENDER_ORDER;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.coderbot.iris.mixin.fantastic;

import net.coderbot.iris.fantastic.IrisParticleTextureSheets;
import net.coderbot.iris.fantastic.IrisParticleRenderTypes;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.TerrainParticle;
Expand Down Expand Up @@ -29,9 +29,9 @@ public class MixinTerrainParticle {
}

@Inject(method = "getRenderType", at = @At("HEAD"), cancellable = true)
private void iris$overrideParticleSheet(CallbackInfoReturnable<ParticleRenderType> cir) {
private void iris$overrideParticleRenderType(CallbackInfoReturnable<ParticleRenderType> cir) {
if (isOpaque) {
cir.setReturnValue(IrisParticleTextureSheets.OPAQUE_TERRAIN_SHEET);
cir.setReturnValue(IrisParticleRenderTypes.OPAQUE_TERRAIN);
}
}
}

0 comments on commit 6b7891d

Please sign in to comment.