generated from VulpixelMC/MDK-1.21-ModDevGradle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(day 3, Na compat): programmer art support
- Loading branch information
Showing
9 changed files
with
117 additions
and
39 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/main/java/gay/sylv/legacy_landscape/client/util/RenderUtil.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,34 @@ | ||
package gay.sylv.legacy_landscape.client.util; | ||
|
||
import gay.sylv.legacy_landscape.client.HackedRenderSystem; | ||
import gay.sylv.legacy_landscape.mixin.client.Accessor_CompositeRenderType; | ||
import gay.sylv.legacy_landscape.mixin.client.Accessor_CompositeState; | ||
import gay.sylv.legacy_landscape.mixin.client.Accessor_TextureStateShard; | ||
import net.minecraft.client.renderer.RenderType; | ||
|
||
public final class RenderUtil { | ||
public static final int WATER_COLOR = 0xFF334FDD; | ||
|
||
private RenderUtil() {} | ||
|
||
public static int saturateTint(int tint) { | ||
int red = (tint & 0x00FF0000) >> 16; | ||
red += 0x28; | ||
red = Math.clamp(red, 0, 0x98); | ||
int green = (tint & 0x0000FF00) >> 8; | ||
green += 0x28; | ||
green = Math.clamp(green, 0, 0xFF); // prevent overflow/underflow | ||
tint = (tint & 0xFF0000FF) | green << 8 | red << 16; // clear green channel and set new green | ||
return tint; | ||
} | ||
|
||
public static void setLegacyTextures(RenderType renderType) { | ||
Accessor_CompositeRenderType compositeRenderType = (Accessor_CompositeRenderType) renderType; | ||
Accessor_CompositeState compositeState = (Accessor_CompositeState) (Object) compositeRenderType.getState(); | ||
assert compositeState != null; | ||
Accessor_TextureStateShard textureState = (Accessor_TextureStateShard) (compositeState.getTextureState()); | ||
if (textureState.getTexture().isPresent()) { | ||
HackedRenderSystem.setShaderTexture(0, textureState.getTexture().get(), textureState.isBlur(), textureState.isMipmap()); | ||
} | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
src/main/java/gay/sylv/legacy_landscape/mixin/client/sodium/Accessor_TerrainRenderPass.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,14 @@ | ||
package gay.sylv.legacy_landscape.mixin.client.sodium; | ||
|
||
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; | ||
import net.minecraft.client.renderer.RenderType; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Pseudo; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(TerrainRenderPass.class) | ||
@Pseudo | ||
public interface Accessor_TerrainRenderPass { | ||
@Accessor | ||
RenderType getRenderType(); | ||
} |
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
53 changes: 53 additions & 0 deletions
53
src/main/java/gay/sylv/legacy_landscape/mixin/client/sodium/Mixin_DefaultChunkRenderer.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,53 @@ | ||
package gay.sylv.legacy_landscape.mixin.client.sodium; | ||
|
||
import gay.sylv.legacy_landscape.client.util.RenderUtil; | ||
import gay.sylv.legacy_landscape.data_attachment.LegacyAttachments; | ||
import net.caffeinemc.mods.sodium.client.gl.device.CommandList; | ||
import net.caffeinemc.mods.sodium.client.gl.device.RenderDevice; | ||
import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices; | ||
import net.caffeinemc.mods.sodium.client.render.chunk.DefaultChunkRenderer; | ||
import net.caffeinemc.mods.sodium.client.render.chunk.ShaderChunkRenderer; | ||
import net.caffeinemc.mods.sodium.client.render.chunk.lists.ChunkRenderListIterable; | ||
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; | ||
import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexType; | ||
import net.caffeinemc.mods.sodium.client.render.viewport.CameraTransform; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.chunk.LevelChunk; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Pseudo; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(DefaultChunkRenderer.class) | ||
@Pseudo | ||
public abstract class Mixin_DefaultChunkRenderer extends ShaderChunkRenderer { | ||
private Mixin_DefaultChunkRenderer( | ||
RenderDevice device, ChunkVertexType vertexType | ||
) { | ||
super(device, vertexType); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
@Inject( | ||
method = "render", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/ShaderChunkRenderer;begin(Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;)V", | ||
shift = At.Shift.AFTER | ||
) | ||
) | ||
private void setLegacyTextures( | ||
ChunkRenderMatrices matrices, CommandList commandList, ChunkRenderListIterable renderLists, TerrainRenderPass renderPass, CameraTransform camera, | ||
CallbackInfo ci | ||
) { | ||
Minecraft client = Minecraft.getInstance(); | ||
assert client.level != null; | ||
LevelChunk chunk = client.level.getChunkAt(BlockPos.containing(camera.x, camera.y, camera.z)); | ||
if (chunk.getData(LegacyAttachments.LEGACY_CHUNK)) { | ||
RenderUtil.setLegacyTextures(((Accessor_TerrainRenderPass) renderPass).getRenderType()); | ||
this.activeProgram.getInterface().setupState(); | ||
} | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
src/main/java/gay/sylv/legacy_landscape/util/TintUtil.java
This file was deleted.
Oops, something went wrong.
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