Skip to content

Commit

Permalink
Merge v7.46pre3 into 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Sep 24, 2024
1 parent 2424ae2 commit 101af58
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 20 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ loader_version=0.16.5
fabric_version=0.92.2+1.20.1

# Mod Properties
mod_version = v7.46pre2-MC1.20.1
mod_version = v7.46pre3-MC1.20.1
maven_group = net.wurstclient
archives_base_name = Wurst-Client

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/wurstclient/WurstClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public enum WurstClient
public static MinecraftClient MC;
public static IMinecraftClient IMC;

public static final String VERSION = "7.46pre2";
public static final String VERSION = "7.46pre3";
public static final String MC_VERSION = "1.20.1";

private WurstAnalytics analytics;
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/net/wurstclient/hacks/BonemealAuraHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import net.minecraft.util.math.Vec3d;
import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.events.PostMotionListener;
import net.wurstclient.events.HandleInputListener;
import net.wurstclient.hack.Hack;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.EnumSetting;
Expand All @@ -35,7 +35,7 @@

@SearchTags({"bonemeal aura", "bone meal aura", "AutoBonemeal", "auto bonemeal",
"auto bone meal", "fertilizer"})
public final class BonemealAuraHack extends Hack implements PostMotionListener
public final class BonemealAuraHack extends Hack implements HandleInputListener
{
private final SliderSetting range =
new SliderSetting("Range", 4.25, 1, 6, 0.05, ValueDisplay.DECIMAL);
Expand Down Expand Up @@ -81,22 +81,25 @@ public BonemealAuraHack()
@Override
protected void onEnable()
{
EVENTS.add(PostMotionListener.class, this);
EVENTS.add(HandleInputListener.class, this);
}

@Override
protected void onDisable()
{
EVENTS.remove(PostMotionListener.class, this);
EVENTS.remove(HandleInputListener.class, this);
}

@Override
public void onPostMotion()
public void onHandleInput()
{
// wait for right click timer
if(MC.itemUseCooldown > 0)
return;

if(MC.interactionManager.isBreakingBlock() || MC.player.isRiding())
return;

// get valid blocks
ArrayList<BlockPos> validBlocks = getValidBlocks();

Expand Down
13 changes: 8 additions & 5 deletions src/main/java/net/wurstclient/hacks/FeedAuraHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import net.minecraft.util.math.Vec3d;
import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.events.PostMotionListener;
import net.wurstclient.events.HandleInputListener;
import net.wurstclient.events.RenderListener;
import net.wurstclient.events.UpdateListener;
import net.wurstclient.hack.Hack;
Expand All @@ -49,7 +49,7 @@
@SearchTags({"feed aura", "BreedAura", "breed aura", "AutoBreeder",
"auto breeder"})
public final class FeedAuraHack extends Hack
implements UpdateListener, PostMotionListener, RenderListener
implements UpdateListener, HandleInputListener, RenderListener
{
private final SliderSetting range = new SliderSetting("Range",
"Determines how far FeedAura will reach to feed animals.\n"
Expand Down Expand Up @@ -97,15 +97,15 @@ protected void onEnable()
WURST.getHax().tpAuraHack.setEnabled(false);

EVENTS.add(UpdateListener.class, this);
EVENTS.add(PostMotionListener.class, this);
EVENTS.add(HandleInputListener.class, this);
EVENTS.add(RenderListener.class, this);
}

@Override
protected void onDisable()
{
EVENTS.remove(UpdateListener.class, this);
EVENTS.remove(PostMotionListener.class, this);
EVENTS.remove(HandleInputListener.class, this);
EVENTS.remove(RenderListener.class, this);

target = null;
Expand Down Expand Up @@ -150,7 +150,7 @@ public void onUpdate()
}

@Override
public void onPostMotion()
public void onHandleInput()
{
if(target == null)
return;
Expand All @@ -159,6 +159,9 @@ public void onPostMotion()
ClientPlayerEntity player = MC.player;
Hand hand = Hand.MAIN_HAND;

if(im.isBreakingBlock() || player.isRiding())
return;

// create realistic hit result
Box box = target.getBoundingBox();
Vec3d start = RotationUtils.getEyesPos();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/wurstclient/hacks/TillauraHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import net.minecraft.util.math.Vec3d;
import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.events.PostMotionListener;
import net.wurstclient.events.HandleInputListener;
import net.wurstclient.hack.Hack;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.SliderSetting;
Expand All @@ -35,7 +35,7 @@
@SearchTags({"till aura", "HoeAura", "hoe aura", "FarmlandAura",
"farmland aura", "farm land aura", "AutoTill", "auto till", "AutoHoe",
"auto hoe"})
public final class TillauraHack extends Hack implements PostMotionListener
public final class TillauraHack extends Hack implements HandleInputListener
{
private final SliderSetting range = new SliderSetting("Range",
"How far Tillaura will reach to till blocks.", 5, 1, 6, 0.05,
Expand Down Expand Up @@ -67,17 +67,17 @@ public TillauraHack()
@Override
protected void onEnable()
{
EVENTS.add(PostMotionListener.class, this);
EVENTS.add(HandleInputListener.class, this);
}

@Override
protected void onDisable()
{
EVENTS.remove(PostMotionListener.class, this);
EVENTS.remove(HandleInputListener.class, this);
}

@Override
public void onPostMotion()
public void onHandleInput()
{
// wait for right click timer
if(MC.itemUseCooldown > 0)
Expand Down
31 changes: 28 additions & 3 deletions src/main/java/net/wurstclient/hacks/XRayHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import net.wurstclient.mixinterface.ISimpleOption;
import net.wurstclient.settings.BlockListSetting;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.SliderSetting;
import net.wurstclient.settings.SliderSetting.ValueDisplay;
import net.wurstclient.util.BlockUtils;
import net.wurstclient.util.ChatUtils;

Expand Down Expand Up @@ -80,6 +82,12 @@ public final class XRayHack extends Hack implements UpdateListener,
+ "Remember to restart X-Ray when changing this setting.",
false);

private final SliderSetting opacity = new SliderSetting("Opacity",
"Opacity of non-ore blocks when X-Ray is enabled.\n\n"
+ "Does not work when Sodium is installed.\n\n"
+ "Remember to restart X-Ray when changing this setting.",
0, 0, 0.99, 0.01, ValueDisplay.PERCENTAGE.withLabel(0, "off"));

private final String optiFineWarning;
private final String renderName =
Math.random() < 0.01 ? "X-Wurst" : getName();
Expand All @@ -94,6 +102,7 @@ public XRayHack()
setCategory(Category.RENDER);
addSetting(ores);
addSetting(onlyExposed);
addSetting(opacity);
optiFineWarning = checkOptiFine();
}

Expand Down Expand Up @@ -167,8 +176,12 @@ public void onGetAmbientOcclusionLightLevel(
@Override
public void onShouldDrawSide(ShouldDrawSideEvent event)
{
event.setRendered(
isVisible(event.getState().getBlock(), event.getPos()));
boolean visible =
isVisible(event.getState().getBlock(), event.getPos());
if(!visible && opacity.getValue() > 0)
return;

event.setRendered(visible);
}

@Override
Expand All @@ -179,7 +192,7 @@ public void onRenderBlockEntity(RenderBlockEntityEvent event)
event.cancel();
}

private boolean isVisible(Block block, BlockPos pos)
public boolean isVisible(Block block, BlockPos pos)
{
String name = BlockUtils.getName(block);
int index = Collections.binarySearch(oreNamesCache, name);
Expand All @@ -201,6 +214,16 @@ private boolean isExposed(BlockPos pos)
return false;
}

public boolean isOpacityMode()
{
return isEnabled() && opacity.getValue() > 0;
}

public int getOpacityColorMask()
{
return (int)(opacity.getValue() * 255) << 24 | 0xFFFFFF;
}

/**
* Checks if OptiFine/OptiFabric is installed and returns a warning message
* if it is.
Expand All @@ -222,4 +245,6 @@ public void openBlockListEditor(Screen prevScreen)
{
MC.setScreen(new EditBlockListScreen(prevScreen, ores));
}

// See AbstractBlockRenderContextMixin, RenderLayersMixin
}
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.
*/
@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());
}
}
37 changes: 37 additions & 0 deletions src/main/java/net/wurstclient/mixin/RenderLayersMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import net.minecraft.block.BlockState;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderLayers;
import net.wurstclient.WurstClient;

@Mixin(RenderLayers.class)
public abstract class RenderLayersMixin
{
/**
* Puts all blocks on the translucent layer if Opacity X-Ray is enabled.
*/
@Inject(at = @At("HEAD"),
method = "getBlockLayer(Lnet/minecraft/block/BlockState;)Lnet/minecraft/client/render/RenderLayer;",
cancellable = true)
private static void onGetBlockLayer(BlockState state,
CallbackInfoReturnable<RenderLayer> cir)
{
if(!WurstClient.INSTANCE.getHax().xRayHack.isOpacityMode())
return;

cir.setReturnValue(RenderLayer.getTranslucent());
}
}
2 changes: 2 additions & 0 deletions src/main/resources/wurst.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [],
"client": [
"AbstractBlockRenderContextMixin",
"AbstractBlockStateMixin",
"AbstractSignEditScreenMixin",
"AllowedAddressResolverMixin",
Expand Down Expand Up @@ -52,6 +53,7 @@
"PlayerInventoryMixin",
"PlayerSkinProviderMixin",
"PowderSnowBlockMixin",
"RenderLayersMixin",
"RenderTickCounterMixin",
"ScreenMixin",
"ShulkerBoxScreenMixin",
Expand Down

0 comments on commit 101af58

Please sign in to comment.