-
-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make X-Ray fully compatible with Sodium
- Loading branch information
Showing
6 changed files
with
106 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ maven_group = net.wurstclient | |
archives_base_name = Wurst-Client | ||
|
||
# Dependencies | ||
sodium_version=mc1.20.2-0.5.3 |
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
42 changes: 42 additions & 0 deletions
42
src/main/java/net/wurstclient/mixin/SodiumBlockRendererMixin.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,42 @@ | ||
/* | ||
* Copyright (c) 2014-2023 Wurst-Imperium and contributors. | ||
* | ||
* This source code is subject to the terms of the GNU General Public | ||
* License, version 3. If a copy of the GPL was not distributed with this | ||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt | ||
*/ | ||
package net.wurstclient.mixin; | ||
|
||
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderContext; | ||
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; | ||
|
||
import net.minecraft.client.render.model.BakedQuad; | ||
import net.minecraft.util.math.Direction; | ||
import net.wurstclient.event.EventManager; | ||
import net.wurstclient.events.ShouldDrawSideListener.ShouldDrawSideEvent; | ||
|
||
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.CallbackInfoReturnable; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(value = BlockRenderer.class, remap = false) | ||
public class SodiumBlockRendererMixin | ||
{ | ||
@Inject(at = @At("HEAD"), | ||
method = "getGeometry", | ||
cancellable = true) | ||
private void getGeometry(BlockRenderContext ctx, Direction face, | ||
CallbackInfoReturnable<List<BakedQuad>> cir) | ||
{ | ||
if (face != null) return; | ||
|
||
ShouldDrawSideEvent event = new ShouldDrawSideEvent(ctx.state(), ctx.pos()); | ||
EventManager.fire(event); | ||
|
||
if (event.isRendered() != null && !event.isRendered()) | ||
cir.setReturnValue(List.of()); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/net/wurstclient/mixin/SodiumFluidRendererMixin.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,42 @@ | ||
/* | ||
* Copyright (c) 2014-2023 Wurst-Imperium and contributors. | ||
* | ||
* This source code is subject to the terms of the GNU General Public | ||
* License, version 3. If a copy of the GPL was not distributed with this | ||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt | ||
*/ | ||
package net.wurstclient.mixin; | ||
|
||
import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.FluidRenderer; | ||
|
||
import net.minecraft.block.BlockState; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.world.BlockRenderView; | ||
import net.wurstclient.event.EventManager; | ||
import net.wurstclient.events.ShouldDrawSideListener.ShouldDrawSideEvent; | ||
|
||
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.CallbackInfoReturnable; | ||
|
||
@Mixin(value = FluidRenderer.class, remap = false) | ||
public class SodiumFluidRendererMixin | ||
{ | ||
@Inject(at = @At("HEAD"), | ||
method = "isSideExposed", | ||
cancellable = true) | ||
private void isSideExposed(BlockRenderView world, | ||
int x, int y, int z, Direction dir, float height, | ||
CallbackInfoReturnable<Boolean> cir) | ||
{ | ||
BlockPos pos = new BlockPos(x, y, z); | ||
BlockState state = world.getBlockState(pos); | ||
ShouldDrawSideEvent event = new ShouldDrawSideEvent(state, pos); | ||
EventManager.fire(event); | ||
|
||
if(event.isRendered() != null) | ||
cir.setReturnValue(event.isRendered()); | ||
} | ||
} |
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