-
-
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.
- Loading branch information
Showing
12 changed files
with
135 additions
and
48 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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
# Done to increase the memory available to gradle. | ||
org.gradle.jvmargs=-Xmx1G | ||
org.gradle.parallel=true | ||
|
||
# Fabric Properties | ||
# check these at https://fabricmc.net/develop/ and | ||
# https://modrinth.com/mod/fabric-api/versions | ||
minecraft_version=1.21.3 | ||
yarn_mappings=1.21.3+build.2 | ||
loader_version=0.16.9 | ||
|
||
# Fabric API | ||
fabric_version=0.110.0+1.21.3 | ||
|
||
# Mod Properties | ||
mod_version = v7.46.4-MC1.21.3 | ||
maven_group = net.wurstclient | ||
archives_base_name = Wurst-Client | ||
|
||
# Dependencies | ||
# Done to increase the memory available to gradle. | ||
org.gradle.jvmargs=-Xmx1G | ||
org.gradle.parallel=true | ||
|
||
# Fabric Properties | ||
# check these at https://fabricmc.net/develop/ and | ||
# https://modrinth.com/mod/fabric-api/versions | ||
minecraft_version=1.21.4 | ||
yarn_mappings=1.21.4+build.1 | ||
loader_version=0.16.9 | ||
|
||
# Fabric API | ||
fabric_version=0.110.5+1.21.4 | ||
|
||
# Mod Properties | ||
mod_version = v7.46.4-MC1.21.4 | ||
maven_group = net.wurstclient | ||
archives_base_name = Wurst-Client | ||
|
||
# Dependencies |
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
79 changes: 79 additions & 0 deletions
79
src/main/java/net/wurstclient/mixin/BlockModelRendererMixin.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,79 @@ | ||
/* | ||
* 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.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
|
||
import net.minecraft.block.BlockState; | ||
import net.minecraft.client.render.VertexConsumer; | ||
import net.minecraft.client.render.block.BlockModelRenderer; | ||
import net.minecraft.client.render.model.BakedModel; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.item.ItemConvertible; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.math.random.Random; | ||
import net.minecraft.world.BlockRenderView; | ||
import net.wurstclient.WurstClient; | ||
import net.wurstclient.event.EventManager; | ||
import net.wurstclient.events.ShouldDrawSideListener.ShouldDrawSideEvent; | ||
import net.wurstclient.hacks.XRayHack; | ||
|
||
@Mixin(BlockModelRenderer.class) | ||
public abstract class BlockModelRendererMixin implements ItemConvertible | ||
{ | ||
private static ThreadLocal<Float> currentOpacity = | ||
ThreadLocal.withInitial(() -> 1F); | ||
|
||
/** | ||
* Makes X-Ray work when neither Sodium nor Indigo are running. | ||
*/ | ||
@WrapOperation(at = @At(value = "INVOKE", | ||
target = "Lnet/minecraft/block/Block;shouldDrawSide(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/Direction;)Z"), | ||
method = { | ||
"renderSmooth(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLnet/minecraft/util/math/random/Random;JI)V", | ||
"renderFlat(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLnet/minecraft/util/math/random/Random;JI)V"}) | ||
private static boolean onRenderSmoothOrFlat(BlockState state, | ||
BlockState otherState, Direction side, Operation<Boolean> original, | ||
BlockRenderView world, BakedModel model, BlockState state2, | ||
BlockPos pos, MatrixStack matrices, VertexConsumer vertexConsumer, | ||
boolean cull, Random random, long seed, int overlay) | ||
{ | ||
ShouldDrawSideEvent event = new ShouldDrawSideEvent(state, pos); | ||
EventManager.fire(event); | ||
|
||
XRayHack xray = WurstClient.INSTANCE.getHax().xRayHack; | ||
if(!xray.isOpacityMode() || xray.isVisible(state.getBlock(), pos)) | ||
currentOpacity.set(1F); | ||
else | ||
currentOpacity.set(xray.getOpacityFloat()); | ||
|
||
if(event.isRendered() != null) | ||
return event.isRendered(); | ||
|
||
return original.call(state, otherState, side); | ||
} | ||
|
||
/** | ||
* Applies X-Ray's opacity mask to the block color after all the normal | ||
* coloring and shading is done, if neither Sodium nor Indigo are running. | ||
*/ | ||
@ModifyConstant( | ||
method = "renderQuad(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/client/util/math/MatrixStack$Entry;Lnet/minecraft/client/render/model/BakedQuad;FFFFIIIII)V", | ||
constant = @Constant(floatValue = 1F)) | ||
private float modifyOpacity(float original) | ||
{ | ||
return currentOpacity.get(); | ||
} | ||
} |
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