Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Merge branch 'v7.43'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Jun 14, 2024
2 parents 9e0a967 + eb6615f commit 0030020
Show file tree
Hide file tree
Showing 33 changed files with 887 additions and 396 deletions.
24 changes: 3 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
buildscript {
dependencies {
classpath 'org.kohsuke:github-api:1.321'
classpath "org.kohsuke:github-api:1.321"
}
}

plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
id 'com.diffplug.spotless' version '6.25.0'
id "fabric-loom" version "1.6-SNAPSHOT"
id "com.diffplug.spotless" version "6.25.0"
}

def ENV = System.getenv()
Expand Down Expand Up @@ -85,23 +84,6 @@ spotless {
}
}

// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

task moveDevLibs(dependsOn: [remapJar, remapSourcesJar]) {
doLast {
ant.move(file:"${project.buildDir}/devlibs/${archivesBaseName}-${version}-dev.jar", tofile:"${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
Expand Down
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.15.11
fabric_version=0.100.1+1.21

# Mod Properties
mod_version = v7.42-MC1.21
mod_version = v7.43-MC1.21
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 @@ -58,7 +58,7 @@ public enum WurstClient
public static MinecraftClient MC;
public static IMinecraftClient IMC;

public static final String VERSION = "7.42";
public static final String VERSION = "7.43";
public static final String MC_VERSION = "1.21";

private WurstAnalytics analytics;
Expand Down
66 changes: 23 additions & 43 deletions src/main/java/net/wurstclient/ai/PathFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.mojang.blaze3d.systems.RenderSystem;

import net.minecraft.block.*;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.LavaFluid;
Expand All @@ -31,20 +32,9 @@

public class PathFinder
{
private final WurstClient wurst = WurstClient.INSTANCE;

private final boolean invulnerable =
WurstClient.MC.player.getAbilities().creativeMode;
private final boolean creativeFlying =
WurstClient.MC.player.getAbilities().flying;
protected final boolean flying =
creativeFlying || wurst.getHax().flightHack.isEnabled();
private final boolean immuneToFallDamage =
invulnerable || wurst.getHax().noFallHack.isEnabled();
private final boolean noWaterSlowdown =
wurst.getHax().antiWaterPushHack.isPreventingSlowdown();
private final boolean jesus = wurst.getHax().jesusHack.isEnabled();
private final boolean spider = wurst.getHax().spiderHack.isEnabled();
private static final MinecraftClient MC = WurstClient.MC;

private final PlayerAbilities abilities = PlayerAbilities.get();
protected boolean fallingAllowed = true;
protected boolean divingAllowed = true;

Expand All @@ -66,13 +56,11 @@ public class PathFinder

public PathFinder(BlockPos goal)
{
if(WurstClient.MC.player.isOnGround())
start = new PathPos(BlockPos.ofFloored(WurstClient.MC.player.getX(),
WurstClient.MC.player.getY() + 0.5,
WurstClient.MC.player.getZ()));
if(MC.player.isOnGround())
start = new PathPos(BlockPos.ofFloored(MC.player.getX(),
MC.player.getY() + 0.5, MC.player.getZ()));
else
start =
new PathPos(BlockPos.ofFloored(WurstClient.MC.player.getPos()));
start = new PathPos(BlockPos.ofFloored(MC.player.getPos()));
this.goal = goal;

costMap.put(start, 0F);
Expand Down Expand Up @@ -196,7 +184,7 @@ private ArrayList<PathPos> getNeighbors(PathPos pos)
}

// up
if(pos.getY() < WurstClient.MC.world.getTopY() && canGoThrough(up.up())
if(pos.getY() < MC.world.getTopY() && canGoThrough(up.up())
&& (flying || onGround || canClimbUpAt(pos))
&& (flying || canClimbUpAt(pos) || goal.equals(up)
|| canSafelyStandOn(north) || canSafelyStandOn(east)
Expand All @@ -205,7 +193,7 @@ private ArrayList<PathPos> getNeighbors(PathPos pos)
neighbors.add(new PathPos(up, onGround));

// down
if(pos.getY() > WurstClient.MC.world.getBottomY() && canGoThrough(down)
if(pos.getY() > MC.world.getBottomY() && canGoThrough(down)
&& canGoAbove(down.down()) && (flying || canFallBelow(pos))
&& (divingAllowed || BlockUtils.getBlock(pos) != Blocks.WATER))
neighbors.add(new PathPos(down));
Expand Down Expand Up @@ -285,8 +273,8 @@ protected boolean canBeSolid(BlockPos pos)
Block block = state.getBlock();

return state.blocksMovement() && !(block instanceof AbstractSignBlock)
|| block instanceof LadderBlock
|| jesus && (block == Blocks.WATER || block == Blocks.LAVA);
|| block instanceof LadderBlock || abilities.jesus()
&& (block == Blocks.WATER || block == Blocks.LAVA);
}

@SuppressWarnings("deprecation")
Expand All @@ -295,7 +283,7 @@ private boolean canGoThrough(BlockPos pos)
// check if loaded
// Can't see why isChunkLoaded() is deprecated. Still seems to be widely
// used with no replacement.
if(!WurstClient.MC.world.isChunkLoaded(pos))
if(!MC.world.isChunkLoaded(pos))
return false;

// check if solid
Expand All @@ -310,7 +298,7 @@ private boolean canGoThrough(BlockPos pos)
return false;

// check if safe
if(!invulnerable
if(!abilities.invulnerable()
&& (block == Blocks.LAVA || block instanceof AbstractFireBlock))
return false;

Expand All @@ -337,7 +325,7 @@ private boolean canSafelyStandOn(BlockPos pos)
// check if safe
BlockState state = BlockUtils.getState(pos);
Fluid fluid = state.getFluidState().getFluid();
if(!invulnerable && (state.getBlock() instanceof CactusBlock
if(!abilities.invulnerable() && (state.getBlock() instanceof CactusBlock
|| fluid instanceof LavaFluid))
return false;

Expand All @@ -356,7 +344,7 @@ private boolean canFallBelow(PathPos pos)
return false;

// check if fall damage is off
if(immuneToFallDamage && fallingAllowed)
if(abilities.immuneToFallDamage() && fallingAllowed)
return true;

// check if fall ends with slime block
Expand Down Expand Up @@ -395,15 +383,15 @@ private boolean canFallBelow(PathPos pos)

private boolean canFlyAt(BlockPos pos)
{
return flying
|| !noWaterSlowdown && BlockUtils.getBlock(pos) == Blocks.WATER;
return abilities.flying() || !abilities.noWaterSlowdown()
&& BlockUtils.getBlock(pos) == Blocks.WATER;
}

private boolean canClimbUpAt(BlockPos pos)
{
// check if this block works for climbing
Block block = BlockUtils.getBlock(pos);
if(!spider && !(block instanceof LadderBlock)
if(!abilities.spider() && !(block instanceof LadderBlock)
&& !(block instanceof VineBlock))
return false;

Expand Down Expand Up @@ -448,7 +436,7 @@ private float getCost(BlockPos current, BlockPos next)
Block block = BlockUtils.getBlock(pos);

// liquids
if(block == Blocks.WATER && !noWaterSlowdown)
if(block == Blocks.WATER && !abilities.noWaterSlowdown())
costs[i] *= 1.3164437838225804F;
else if(block == Blocks.LAVA)
costs[i] *= 4.539515393656079F;
Expand Down Expand Up @@ -624,15 +612,7 @@ public boolean isPathStillValid(int index)
throw new IllegalStateException("Path is not formatted!");

// check player abilities
if(invulnerable != WurstClient.MC.player.getAbilities().creativeMode
|| flying != (creativeFlying
|| wurst.getHax().flightHack.isEnabled())
|| immuneToFallDamage != (invulnerable
|| wurst.getHax().noFallHack.isEnabled())
|| noWaterSlowdown != wurst.getHax().antiWaterPushHack
.isPreventingSlowdown()
|| jesus != wurst.getHax().jesusHack.isEnabled()
|| spider != wurst.getHax().spiderHack.isEnabled())
if(!abilities.equals(PlayerAbilities.get()))
return false;

// if index is zero, check if first pos is safe
Expand All @@ -654,8 +634,8 @@ public boolean isPathStillValid(int index)

public PathProcessor getProcessor()
{
if(flying)
return new FlyPathProcessor(path, creativeFlying);
if(abilities.flying())
return new FlyPathProcessor(path, abilities.creativeFlying());

return new WalkPathProcessor(path);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/wurstclient/ai/PathProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static final void lockControls()
key.setPressed(false);

// disable sprinting
WurstClient.MC.player.setSprinting(false);
MC.player.setSprinting(false);
}

public static final void releaseControls()
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/net/wurstclient/ai/PlayerAbilities.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.ai;

import net.minecraft.client.MinecraftClient;
import net.wurstclient.WurstClient;
import net.wurstclient.hack.HackList;

public record PlayerAbilities(boolean invulnerable, boolean creativeFlying,
boolean flying, boolean immuneToFallDamage, boolean noWaterSlowdown,
boolean jesus, boolean spider)
{

private static final WurstClient WURST = WurstClient.INSTANCE;
private static final MinecraftClient MC = WurstClient.MC;

public static PlayerAbilities get()
{
HackList hax = WURST.getHax();
net.minecraft.entity.player.PlayerAbilities mcAbilities =
MC.player.getAbilities();

boolean invulnerable =
mcAbilities.invulnerable || mcAbilities.creativeMode;
boolean creativeFlying = mcAbilities.flying;
boolean flying = creativeFlying || hax.flightHack.isEnabled();
boolean immuneToFallDamage = invulnerable || hax.noFallHack.isEnabled();
boolean noWaterSlowdown = hax.antiWaterPushHack.isPreventingSlowdown();
boolean jesus = hax.jesusHack.isEnabled();
boolean spider = hax.spiderHack.isEnabled();

return new PlayerAbilities(invulnerable, creativeFlying, flying,
immuneToFallDamage, noWaterSlowdown, jesus, spider);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -153,7 +155,13 @@ private static String getAuthorizationCode(String email, String password)

System.out.println("Getting login cookies...");
cookie = "";
for(String c : connection.getHeaderFields().get("Set-Cookie"))
List<String> cookies =
connection.getHeaderFields().get("Set-Cookie");

if(cookies == null)
cookies = Collections.emptyList();

for(String c : cookies)
{
String cookieTrimmed = c.substring(0, c.indexOf(";") + 1);
cookie += cookieTrimmed;
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/net/wurstclient/events/HandleInputListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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.events;

import java.util.ArrayList;

import net.minecraft.client.MinecraftClient;
import net.wurstclient.event.Event;
import net.wurstclient.event.Listener;

/**
* Fired at the beginning of {@link MinecraftClient#handleInputEvents()}.
* This is the ideal time to simulate keyboard input.
*/
public interface HandleInputListener extends Listener
{
/**
* Fired at the beginning of {@link MinecraftClient#handleInputEvents()}.
* This is the ideal time to simulate keyboard input.
*/
public void onHandleInput();

/**
* Fired at the beginning of {@link MinecraftClient#handleInputEvents()}.
* This is the ideal time to simulate keyboard input.
*/
public static class HandleInputEvent extends Event<HandleInputListener>
{
public static final HandleInputEvent INSTANCE = new HandleInputEvent();

@Override
public void fire(ArrayList<HandleInputListener> listeners)
{
for(HandleInputListener listener : listeners)
listener.onHandleInput();
}

@Override
public Class<HandleInputListener> getListenerType()
{
return HandleInputListener.class;
}
}
}
Loading

0 comments on commit 0030020

Please sign in to comment.