-
-
Notifications
You must be signed in to change notification settings - Fork 417
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 work with Fabric API 0.110.5
This reverts commit 753c757.
- Loading branch information
1 parent
0e409bd
commit 5019749
Showing
5 changed files
with
99 additions
and
4 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
47 changes: 47 additions & 0 deletions
47
src/main/java/net/wurstclient/mixin/AbstractBlockRenderContextMixin.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,47 @@ | ||
/* | ||
* Copyright (c) 2014-2024 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 org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import net.fabricmc.fabric.impl.client.indigo.renderer.mesh.MutableQuadViewImpl; | ||
import net.fabricmc.fabric.impl.client.indigo.renderer.render.AbstractBlockRenderContext; | ||
import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderInfo; | ||
import net.wurstclient.WurstClient; | ||
import net.wurstclient.hacks.XRayHack; | ||
|
||
@Mixin(value = AbstractBlockRenderContext.class, remap = false) | ||
public abstract class AbstractBlockRenderContextMixin | ||
{ | ||
@Shadow | ||
@Final | ||
private BlockRenderInfo blockInfo; | ||
|
||
/** | ||
* Applies X-Ray's opacity mask to the block color after all the normal | ||
* coloring and shading is done, if Indigo is running. | ||
*/ | ||
@Inject(at = @At("RETURN"), | ||
method = "shadeQuad(Lnet/fabricmc/fabric/impl/client/indigo/renderer/mesh/MutableQuadViewImpl;ZZZ)V") | ||
private void onShadeQuad(MutableQuadViewImpl quad, boolean ao, | ||
boolean emissive, boolean vanillaShade, CallbackInfo ci) | ||
{ | ||
XRayHack xray = WurstClient.INSTANCE.getHax().xRayHack; | ||
if(!xray.isOpacityMode() || xray | ||
.isVisible(blockInfo.blockState.getBlock(), blockInfo.blockPos)) | ||
return; | ||
|
||
for(int i = 0; i < 4; i++) | ||
quad.color(i, quad.color(i) & xray.getOpacityColorMask()); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/net/wurstclient/mixin/BlockRenderInfoMixin.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,46 @@ | ||
/* | ||
* Copyright (c) 2014-2024 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 org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderInfo; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.wurstclient.event.EventManager; | ||
import net.wurstclient.events.ShouldDrawSideListener.ShouldDrawSideEvent; | ||
|
||
@Mixin(value = BlockRenderInfo.class, remap = false) | ||
public abstract class BlockRenderInfoMixin | ||
{ | ||
@Shadow | ||
public BlockPos blockPos; | ||
@Shadow | ||
public BlockState blockState; | ||
|
||
/** | ||
* This mixin hides and shows regular blocks when using X-Ray, if Indigo | ||
* is running and Sodium is not installed. | ||
*/ | ||
@Inject(at = @At("HEAD"), method = "shouldDrawSide", cancellable = true) | ||
private void onShouldDrawSide(Direction face, | ||
CallbackInfoReturnable<Boolean> cir) | ||
{ | ||
ShouldDrawSideEvent event = | ||
new ShouldDrawSideEvent(blockState, blockPos); | ||
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
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