0
0
mirror of https://github.com/Wurst-Imperium/Wurst7.git synced 2024-09-19 17:02:13 +02:00

Merge branch 'master' into v7.42

This commit is contained in:
Alexander01998 2024-04-29 23:30:15 +02:00
commit 092fa0b12a
56 changed files with 402 additions and 420 deletions

View File

@ -28,10 +28,10 @@ jobs:
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
- name: Set up Java 17
- name: Set up Java 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'microsoft'
- name: Grant execute permission for gradlew

View File

@ -6,7 +6,7 @@
## Setup (for developers)
(This assumes that you are using Windows with [Eclipse](https://www.eclipse.org/downloads/) and [Java Development Kit 17](https://adoptium.net/?variant=openjdk17&jvmVariant=hotspot) already installed.)
(This assumes that you are using Windows with [Eclipse](https://www.eclipse.org/downloads/) and [Java Development Kit 21](https://adoptium.net/?variant=openjdk21&jvmVariant=hotspot) already installed.)
1. Run this command in PowerShell:

View File

@ -12,8 +12,8 @@ plugins {
def ENV = System.getenv()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
archivesBaseName = project.archives_base_name
version = project.mod_version
@ -58,8 +58,8 @@ processResources {
}
tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
// Minecraft 1.20.5 (24w14a) upwards uses Java 21.
it.options.release = 21
}
java {

View File

@ -5,15 +5,15 @@ org.gradle.parallel=true
# Fabric Properties
# check these at https://fabricmc.net/develop/ and
# https://www.curseforge.com/minecraft/mc-mods/fabric-api
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.10
#Fabric api
fabric_version=0.97.0+1.20.4
fabric_version=0.97.8+1.20.6
# Mod Properties
mod_version = v7.42pre2-MC1.20.4
mod_version = v7.42pre2-MC1.20.6
maven_group = net.wurstclient
archives_base_name = Wurst-Client

Binary file not shown.

View File

@ -59,7 +59,7 @@ public enum WurstClient
public static IMinecraftClient IMC;
public static final String VERSION = "7.42pre2";
public static final String MC_VERSION = "1.20.4";
public static final String MC_VERSION = "1.20.6";
private WurstAnalytics analytics;
private EventManager eventManager;

View File

@ -14,6 +14,7 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
@ -197,7 +198,7 @@ public enum MicrosoftLoginManager
try
{
URL url = new URL(urlPost);
URL url = URI.create(urlPost).toURL();
HttpURLConnection connection =
(HttpURLConnection)url.openConnection();
@ -504,7 +505,7 @@ public enum MicrosoftLoginManager
{
try
{
return new URL(url);
return URI.create(url).toURL();
}catch(MalformedURLException e)
{

View File

@ -30,6 +30,7 @@ import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.Proxy.Type;
import java.net.SocketAddress;
import java.net.URI;
import java.net.URL;
import java.util.LinkedList;
import java.util.Scanner;
@ -532,7 +533,7 @@ public class JGoogleAnalyticsTracker
{
try
{
URL url = new URL(argURL);
URL url = URI.create(argURL).toURL();
HttpURLConnection connection =
(HttpURLConnection)url.openConnection(proxy);
connection.setRequestMethod("GET");

View File

@ -291,6 +291,8 @@ public final class AddBookOfferScreen extends Screen
float partialTicks)
{
MatrixStack matrixStack = context.getMatrices();
renderBackground(context, mouseX, mouseY, partialTicks);
listGui.render(context, mouseX, mouseY, partialTicks);
matrixStack.push();

View File

@ -165,6 +165,8 @@ public final class EditBlockListScreen extends Screen
float partialTicks)
{
MatrixStack matrixStack = context.getMatrices();
renderBackground(context, mouseX, mouseY, partialTicks);
listGui.render(context, mouseX, mouseY, partialTicks);
context.drawCenteredTextWithShadow(client.textRenderer,

View File

@ -254,7 +254,7 @@ public final class EditBookOfferScreen extends Screen
float partialTicks)
{
MatrixStack matrixStack = context.getMatrices();
renderBackgroundTexture(context);
renderBackground(context, mouseX, mouseY, partialTicks);
matrixStack.push();
matrixStack.translate(0, 0, 300);

View File

@ -183,6 +183,8 @@ public final class EditBookOffersScreen extends Screen
float partialTicks)
{
MatrixStack matrixStack = context.getMatrices();
renderBackground(context, mouseX, mouseY, partialTicks);
listGui.render(context, mouseX, mouseY, partialTicks);
matrixStack.push();

View File

@ -167,6 +167,8 @@ public final class EditItemListScreen extends Screen
float partialTicks)
{
MatrixStack matrixStack = context.getMatrices();
renderBackground(context, mouseX, mouseY, partialTicks);
listGui.render(context, mouseX, mouseY, partialTicks);
context.drawCenteredTextWithShadow(client.textRenderer,

View File

@ -7,10 +7,10 @@
*/
package net.wurstclient.commands;
import net.minecraft.item.Item;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.WrittenBookContentComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtString;
import net.wurstclient.command.CmdError;
import net.wurstclient.command.CmdException;
import net.wurstclient.command.CmdSyntaxError;
@ -33,15 +33,20 @@ public final class AuthorCmd extends Command
if(!MC.player.getAbilities().creativeMode)
throw new CmdError("Creative mode only.");
ItemStack heldItem = MC.player.getInventory().getMainHandStack();
int heldItemID = Item.getRawId(heldItem.getItem());
int writtenBookID = Item.getRawId(Items.WRITTEN_BOOK);
if(heldItemID != writtenBookID)
ItemStack heldStack = MC.player.getInventory().getMainHandStack();
if(!heldStack.isOf(Items.WRITTEN_BOOK))
throw new CmdError(
"You must hold a written book in your main hand.");
WrittenBookContentComponent oldData = heldStack.getComponents()
.get(DataComponentTypes.WRITTEN_BOOK_CONTENT);
if(oldData == null)
throw new CmdError("Can't find book data.");
String author = String.join(" ", args);
heldItem.setSubNbt("author", NbtString.of(author));
WrittenBookContentComponent newData =
new WrittenBookContentComponent(oldData.title(), author,
oldData.generation(), oldData.pages(), oldData.resolved());
heldStack.set(DataComponentTypes.WRITTEN_BOOK_CONTENT, newData);
}
}

View File

@ -16,7 +16,6 @@ import net.wurstclient.command.CmdException;
import net.wurstclient.command.CmdSyntaxError;
import net.wurstclient.command.Command;
import net.wurstclient.util.ChatUtils;
import net.wurstclient.util.ItemUtils;
public final class EnchantCmd extends Command
{
@ -71,7 +70,7 @@ public final class EnchantCmd extends Command
continue;
}
ItemUtils.addEnchantment(stack, enchantment, level);
stack.addEnchantment(enchantment, level);
}
}

View File

@ -11,6 +11,8 @@ import java.util.Arrays;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.NbtComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
@ -83,7 +85,7 @@ public final class GiveCmd extends Command
try
{
NbtCompound tag = StringNbtReader.parse(nbt);
stack.setNbt(tag);
NbtComponent.set(DataComponentTypes.CUSTOM_DATA, stack, tag);
}catch(CommandSyntaxException e)
{

View File

@ -12,6 +12,8 @@ import java.util.Arrays;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.NbtComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.StringNbtReader;
@ -77,16 +79,19 @@ public final class ModifyCmd extends Command
private void add(ItemStack stack, String[] args) throws CmdError
{
String nbt = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
nbt = nbt.replace("$", "\u00a7").replace("\u00a7\u00a7", "$");
String nbtString =
String.join(" ", Arrays.copyOfRange(args, 1, args.length))
.replace("$", "\u00a7").replace("\u00a7\u00a7", "$");
if(!stack.hasNbt())
stack.setNbt(new NbtCompound());
NbtCompound itemNbt = stack
.getOrDefault(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT)
.copyNbt();
try
{
NbtCompound tag = StringNbtReader.parse(nbt);
stack.getNbt().copyFrom(tag);
NbtCompound parsedNbt = StringNbtReader.parse(nbtString);
itemNbt.copyFrom(parsedNbt);
stack.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(itemNbt));
}catch(CommandSyntaxException e)
{
@ -103,7 +108,7 @@ public final class ModifyCmd extends Command
try
{
NbtCompound tag = StringNbtReader.parse(nbt);
stack.setNbt(tag);
stack.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(tag));
}catch(CommandSyntaxException e)
{
@ -117,12 +122,15 @@ public final class ModifyCmd extends Command
if(args.length > 2)
throw new CmdSyntaxError();
NbtPath path = parseNbtPath(stack.getNbt(), args[1]);
NbtPath path = parseNbtPath(stack
.getOrDefault(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT)
.copyNbt(), args[1]);
if(path == null)
throw new CmdError("The path does not exist.");
path.base.remove(path.key);
stack.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(path.base));
}
private NbtPath parseNbtPath(NbtCompound tag, String path)

View File

@ -8,15 +8,17 @@
package net.wurstclient.commands;
import java.util.ArrayList;
import java.util.Optional;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.PotionContentsComponent;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.item.ItemStack;
import net.minecraft.item.PotionItem;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionUtil;
import net.minecraft.potion.Potions;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException;
import net.wurstclient.command.CmdError;
@ -59,19 +61,23 @@ public final class PotionCmd extends Command
if((args.length - 1) % 3 != 0)
throw new CmdSyntaxError();
PotionContentsComponent oldContents = stack.getComponents()
.getOrDefault(DataComponentTypes.POTION_CONTENTS,
PotionContentsComponent.DEFAULT);
// get effects to start with
ArrayList<StatusEffectInstance> effects;
Potion potion;
Optional<RegistryEntry<Potion>> potion;
switch(args[0].toLowerCase())
{
case "add":
effects = new ArrayList<>(PotionUtil.getCustomPotionEffects(stack));
potion = PotionUtil.getPotion(stack);
effects = new ArrayList<>(oldContents.customEffects());
potion = oldContents.potion();
break;
case "set":
effects = new ArrayList<>();
potion = Potions.EMPTY;
potion = Optional.empty();
break;
default:
@ -81,15 +87,16 @@ public final class PotionCmd extends Command
// add new effects
for(int i = 0; i < (args.length - 1) / 3; i++)
{
StatusEffect effect = parseEffect(args[1 + i * 3]);
RegistryEntry<StatusEffect> effect = parseEffect(args[1 + i * 3]);
int amplifier = parseInt(args[2 + i * 3]) - 1;
int duration = parseInt(args[3 + i * 3]) * 20;
effects.add(new StatusEffectInstance(effect, duration, amplifier));
}
PotionUtil.setPotion(stack, potion);
setCustomPotionEffects(stack, effects);
stack.set(DataComponentTypes.POTION_CONTENTS,
new PotionContentsComponent(potion, oldContents.customColor(),
effects));
ChatUtils.message("Potion modified.");
}
@ -98,28 +105,36 @@ public final class PotionCmd extends Command
if(args.length != 2)
throw new CmdSyntaxError();
StatusEffect targetEffect = parseEffect(args[1]);
RegistryEntry<StatusEffect> targetEffect = parseEffect(args[1]);
Potion oldPotion = PotionUtil.getPotion(stack);
boolean mainPotionContainsTargetEffect = oldPotion.getEffects().stream()
.anyMatch(effect -> effect.getEffectType() == targetEffect);
PotionContentsComponent oldContents = stack.getComponents()
.getOrDefault(DataComponentTypes.POTION_CONTENTS,
PotionContentsComponent.DEFAULT);
boolean mainPotionContainsTargetEffect =
oldContents.potion().isPresent()
&& oldContents.potion().get().value().getEffects().stream()
.anyMatch(effect -> effect.getEffectType() == targetEffect);
ArrayList<StatusEffectInstance> newEffects = new ArrayList<>();
if(mainPotionContainsTargetEffect)
PotionUtil.getPotionEffects(stack).forEach(newEffects::add);
oldContents.getEffects().forEach(newEffects::add);
else
PotionUtil.getCustomPotionEffects(stack).forEach(newEffects::add);
oldContents.customEffects().forEach(newEffects::add);
newEffects.removeIf(effect -> effect.getEffectType() == targetEffect);
Potion newPotion =
mainPotionContainsTargetEffect ? Potions.EMPTY : oldPotion;
Optional<RegistryEntry<Potion>> newPotion =
mainPotionContainsTargetEffect ? Optional.empty()
: oldContents.potion();
stack.set(DataComponentTypes.POTION_CONTENTS,
new PotionContentsComponent(newPotion, oldContents.customColor(),
newEffects));
PotionUtil.setPotion(stack, newPotion);
setCustomPotionEffects(stack, newEffects);
ChatUtils.message("Effect removed.");
}
private StatusEffect parseEffect(String input) throws CmdSyntaxError
private RegistryEntry<StatusEffect> parseEffect(String input)
throws CmdSyntaxError
{
StatusEffect effect;
@ -139,17 +154,7 @@ public final class PotionCmd extends Command
if(effect == null)
throw new CmdSyntaxError("Invalid effect: " + input);
return Registries.STATUS_EFFECT.getEntry(effect).value();
}
private void setCustomPotionEffects(ItemStack stack,
ArrayList<StatusEffectInstance> effects)
{
// PotionUtil doesn't remove effects when passing an empty list to it
if(effects.isEmpty())
stack.removeSubNbt("custom_potion_effects");
else
PotionUtil.setCustomPotionEffects(stack, effects);
return Registries.STATUS_EFFECT.getEntry(effect);
}
private int parseInt(String s) throws CmdSyntaxError

View File

@ -7,6 +7,7 @@
*/
package net.wurstclient.commands;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.wurstclient.command.CmdError;
@ -38,12 +39,12 @@ public final class RenameCmd extends Command
message += " " + args[i];
message = message.replace("$", "\u00a7").replace("\u00a7\u00a7", "$");
ItemStack item = MC.player.getInventory().getMainHandStack();
ItemStack stack = MC.player.getInventory().getMainHandStack();
if(item == null)
if(stack == null)
throw new CmdError("There is no item in your hand.");
item.setCustomName(Text.literal(message));
ChatUtils.message("Renamed item to \"" + message + "\u00a7r\".");
stack.set(DataComponentTypes.CUSTOM_NAME, Text.literal(message));
ChatUtils.message("Renamed item to \"\u00a7o" + message + "\u00a7r\".");
}
}

View File

@ -8,6 +8,8 @@
package net.wurstclient.commands;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.NbtComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.wurstclient.SearchTags;
@ -34,17 +36,19 @@ public final class ViewNbtCmd extends Command
if(stack.isEmpty())
throw new CmdError("You must hold an item in your main hand.");
NbtCompound tag = stack.getNbt();
String nbt = tag == null ? "" : tag.asString();
NbtCompound tag = stack
.getOrDefault(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT)
.copyNbt();
String nbtString = tag.asString();
switch(String.join(" ", args).toLowerCase())
{
case "":
ChatUtils.message("NBT: " + nbt);
ChatUtils.message("NBT: " + nbtString);
break;
case "copy":
MC.keyboard.setClipboard(nbt);
MC.keyboard.setClipboard(nbtString);
ChatUtils.message("NBT data copied to clipboard.");
break;

View File

@ -1,42 +0,0 @@
/*
* 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.wurstclient.event.Event;
import net.wurstclient.event.Listener;
public interface HitResultRayTraceListener extends Listener
{
public void onHitResultRayTrace(float partialTicks);
public static class HitResultRayTraceEvent
extends Event<HitResultRayTraceListener>
{
private float partialTicks;
public HitResultRayTraceEvent(float partialTicks)
{
this.partialTicks = partialTicks;
}
@Override
public void fire(ArrayList<HitResultRayTraceListener> listeners)
{
for(HitResultRayTraceListener listener : listeners)
listener.onHitResultRayTrace(partialTicks);
}
@Override
public Class<HitResultRayTraceListener> getListenerType()
{
return HitResultRayTraceListener.class;
}
}
}

View File

@ -175,8 +175,8 @@ public final class AutoArmorHack extends Hack
{
int armorPoints = item.getProtection();
int prtPoints = 0;
int armorToughness = (int)item.toughness;
int armorType = item.getMaterial().getProtection(Type.LEGGINGS);
int armorToughness = (int)item.getToughness();
int armorType = item.getMaterial().value().getProtection(Type.LEGGINGS);
if(useEnchantments.isChecked())
{

View File

@ -11,23 +11,23 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.stream.Stream;
import com.mojang.datafixers.util.Pair;
import net.minecraft.block.Block;
import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.CraftingTableBlock;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.FoodComponent;
import net.minecraft.component.type.FoodComponent.StatusEffectEntry;
import net.minecraft.component.type.FoodComponents;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.entity.player.HungerManager;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.FoodComponents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;
@ -216,21 +216,21 @@ public final class AutoEatHack extends Hack implements UpdateListener
.forEach(i -> slots.add(i));
Comparator<FoodComponent> comparator =
Comparator.comparingDouble(FoodComponent::getSaturationModifier);
Comparator.comparingDouble(FoodComponent::saturation);
for(int slot : slots)
{
Item item = inventory.getStack(slot).getItem();
ItemStack stack = inventory.getStack(slot);
// filter out non-food items
if(!item.isFood())
if(!stack.contains(DataComponentTypes.FOOD))
continue;
FoodComponent food = item.getFoodComponent();
FoodComponent food = stack.get(DataComponentTypes.FOOD);
if(!isAllowedFood(food))
continue;
if(maxPoints >= 0 && food.getHunger() > maxPoints)
if(maxPoints >= 0 && food.nutrition() > maxPoints)
continue;
// compare to previously found food
@ -274,9 +274,9 @@ public final class AutoEatHack extends Hack implements UpdateListener
if(!allowChorus.isChecked() && food == FoodComponents.CHORUS_FRUIT)
return false;
for(Pair<StatusEffectInstance, Float> pair : food.getStatusEffects())
for(StatusEffectEntry entry : food.effects())
{
StatusEffect effect = pair.getFirst().getEffectType();
RegistryEntry<StatusEffect> effect = entry.effect().getEffectType();
if(!allowHunger.isChecked() && effect == StatusEffects.HUNGER)
return false;

View File

@ -9,6 +9,7 @@ package net.wurstclient.hacks;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
@ -16,17 +17,21 @@ import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.systems.RenderSystem;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry;
import net.minecraft.block.Blocks;
import net.minecraft.client.gui.screen.ingame.MerchantScreen;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.item.EnchantedBookItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtList;
import net.minecraft.network.packet.c2s.play.SelectMerchantTradeC2SPacket;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
@ -415,20 +420,23 @@ public final class AutoLibrarianHack extends Hack
if(!(stack.getItem() instanceof EnchantedBookItem))
continue;
NbtList enchantmentNbt = EnchantedBookItem.getEnchantmentNbt(stack);
if(enchantmentNbt.isEmpty())
Set<Entry<RegistryEntry<Enchantment>>> enchantmentLevelMap =
EnchantmentHelper.getEnchantments(stack).getEnchantmentsMap();
if(enchantmentLevelMap.isEmpty())
continue;
NbtList bookNbt = EnchantedBookItem.getEnchantmentNbt(stack);
String enchantment = bookNbt.getCompound(0).getString("id");
int level = bookNbt.getCompound(0).getInt("lvl");
int price = tradeOffer.getAdjustedFirstBuyItem().getCount();
Object2IntMap.Entry<RegistryEntry<Enchantment>> firstEntry =
enchantmentLevelMap.stream().findFirst().orElseThrow();
String enchantment = firstEntry.getKey().getIdAsString();
int level = firstEntry.getIntValue();
int price = tradeOffer.getDisplayedFirstBuyItem().getCount();
BookOffer bookOffer = new BookOffer(enchantment, level, price);
if(!bookOffer.isValid())
{
System.out.println("Found invalid enchanted book offer.\n"
+ "NBT data: " + stack.getNbt());
+ "Component data: " + enchantmentLevelMap);
continue;
}

View File

@ -7,18 +7,16 @@
*/
package net.wurstclient.hacks;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.PotionUtil;
import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.events.UpdateListener;
import net.wurstclient.hack.Hack;
import net.wurstclient.settings.SliderSetting;
import net.wurstclient.settings.SliderSetting.ValueDisplay;
import net.wurstclient.util.ItemUtils;
import net.wurstclient.util.Rotation;
@SearchTags({"AutoPotion", "auto potion", "AutoSplashPotion",
@ -111,24 +109,10 @@ public final class AutoPotionHack extends Hack implements UpdateListener
continue;
// search for instant health effects
if(hasEffect(stack, StatusEffects.INSTANT_HEALTH))
if(ItemUtils.hasEffect(stack, StatusEffects.INSTANT_HEALTH))
return i;
}
return -1;
}
private boolean hasEffect(ItemStack stack, StatusEffect effect)
{
for(StatusEffectInstance effectInstance : PotionUtil
.getPotionEffects(stack))
{
if(effectInstance.getEffectType() != effect)
continue;
return true;
}
return false;
}
}

View File

@ -9,12 +9,11 @@ package net.wurstclient.hacks;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityGroup;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.MiningToolItem;
import net.minecraft.item.SwordItem;
import net.minecraft.item.ToolItem;
import net.minecraft.item.TridentItem;
import net.minecraft.util.hit.EntityHitResult;
@ -153,18 +152,16 @@ public final class AutoSwordHack extends Hack implements UpdateListener
switch(priority.getSelected())
{
case SPEED:
return ItemUtils.getAttackSpeed(item);
return (float)ItemUtils
.getAttribute(item, EntityAttributes.GENERIC_ATTACK_SPEED)
.orElseThrow();
case DAMAGE:
EntityGroup group = entity instanceof LivingEntity le
? le.getGroup() : EntityGroup.DEFAULT;
float dmg = EnchantmentHelper.getAttackDamage(stack, group);
if(item instanceof SwordItem sword)
dmg += sword.getAttackDamage();
if(item instanceof MiningToolItem tool)
dmg += tool.getAttackDamage();
if(item instanceof TridentItem)
dmg += TridentItem.ATTACK_DAMAGE;
EntityType<?> group = entity.getType();
float dmg = (float)ItemUtils
.getAttribute(item, EntityAttributes.GENERIC_ATTACK_DAMAGE)
.orElseThrow();
dmg += EnchantmentHelper.getAttackDamage(stack, group);
return dmg;
}

View File

@ -191,7 +191,7 @@ public final class AutoToolHack extends Hack
private boolean isDamageable(ItemStack stack)
{
return !stack.isEmpty() && stack.getItem().isDamageable();
return !stack.isEmpty() && stack.isDamageable();
}
private boolean isTooDamaged(ItemStack stack, int repairMode)

View File

@ -8,6 +8,8 @@
package net.wurstclient.hacks;
import net.minecraft.block.Blocks;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.NbtComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
@ -51,8 +53,8 @@ public final class CrashChestHack extends Hack
for(int i = 0; i < 40000; i++)
nbtList.add(new NbtList());
nbtCompound.put("www.wurstclient.net", nbtList);
stack.setNbt(nbtCompound);
stack.setCustomName(Text.literal("Copy Me"));
stack.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(nbtCompound));
stack.set(DataComponentTypes.CUSTOM_NAME, Text.literal("Copy Me"));
// give item
MC.player.getInventory().armor.set(0, stack);

View File

@ -7,11 +7,16 @@
*/
package net.wurstclient.hacks;
import java.util.List;
import java.util.Optional;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.PotionContentsComponent;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket;
import net.minecraft.text.Text;
import net.wurstclient.Category;
@ -106,21 +111,18 @@ public final class KillPotionHack extends Hack
{
ItemStack stack = new ItemStack(item);
NbtCompound effect = new NbtCompound();
effect.putInt("amplifier", 125);
effect.putInt("duration", 2000);
effect.putString("id", "instant_health");
StatusEffectInstance effect = new StatusEffectInstance(
StatusEffects.INSTANT_HEALTH, 2000, 125);
NbtList effects = new NbtList();
effects.add(effect);
PotionContentsComponent potionContents =
new PotionContentsComponent(Optional.empty(), Optional.empty(),
List.of(effect));
NbtCompound nbt = new NbtCompound();
nbt.put("custom_potion_effects", effects);
stack.setNbt(nbt);
stack.set(DataComponentTypes.POTION_CONTENTS, potionContents);
String name =
"\u00a7f" + itemName + " of \u00a74\u00a7lINSTANT DEATH";
stack.setCustomName(Text.literal(name));
stack.set(DataComponentTypes.CUSTOM_NAME, Text.literal(name));
return stack;
}

View File

@ -8,10 +8,9 @@
package net.wurstclient.hacks;
import net.wurstclient.Category;
import net.wurstclient.events.HitResultRayTraceListener;
import net.wurstclient.hack.Hack;
public final class LiquidsHack extends Hack implements HitResultRayTraceListener
public final class LiquidsHack extends Hack
{
public LiquidsHack()
{
@ -19,23 +18,5 @@ public final class LiquidsHack extends Hack implements HitResultRayTraceListener
setCategory(Category.BLOCKS);
}
@Override
protected void onEnable()
{
EVENTS.add(HitResultRayTraceListener.class, this);
}
@Override
protected void onDisable()
{
EVENTS.remove(HitResultRayTraceListener.class, this);
}
@Override
public void onHitResultRayTrace(float partialTicks)
{
float reach = MC.interactionManager.getReachDistance();
MC.crosshairTarget =
MC.getCameraEntity().raycast(reach, partialTicks, true);
}
// See GameRendererMixin.liquidsRaycast()
}

View File

@ -13,6 +13,7 @@ import net.wurstclient.hack.Hack;
import net.wurstclient.settings.SliderSetting;
import net.wurstclient.settings.SliderSetting.ValueDisplay;
// TODO: Remove this hack in 1.20.5, as it seems to be patched.
@SearchTags({"range"})
public final class ReachHack extends Hack
{
@ -26,11 +27,11 @@ public final class ReachHack extends Hack
addSetting(range);
}
public float getReachDistance()
public double getReachDistance()
{
return range.getValueF();
return range.getValue();
}
// See ClientPlayerInteractionManagerMixin.onGetReachDistance() and
// ClientPlayerInteractionManagerMixin.hasExtendedReach()
// See ClientPlayerEntityMixin.method_55754() and
// ClientPlayerEntityMixin.method_55755()
}

View File

@ -67,7 +67,7 @@ public final class SafeWalkHack extends Hack
}
Box box = player.getBoundingBox();
Box adjustedBox = box.stretch(0, -player.stepHeight, 0)
Box adjustedBox = box.stretch(0, -player.getStepHeight(), 0)
.expand(-edgeDistance.getValue(), 0, -edgeDistance.getValue());
if(MC.world.isSpaceEmpty(player, adjustedBox))

View File

@ -48,23 +48,15 @@ public final class StepHack extends Hack implements UpdateListener
protected void onDisable()
{
EVENTS.remove(UpdateListener.class, this);
MC.player.stepHeight = 0.5F;
}
@Override
public void onUpdate()
{
if(mode.getSelected() == Mode.SIMPLE)
{
// simple mode
MC.player.stepHeight = height.getValueF();
return;
}
// legit mode
ClientPlayerEntity player = MC.player;
player.stepHeight = 0.5F;
if(!player.horizontalCollision)
return;
@ -80,7 +72,6 @@ public final class StepHack extends Hack implements UpdateListener
return;
Box box = player.getBoundingBox().offset(0, 0.05, 0).expand(0.05);
if(!MC.world.isSpaceEmpty(player, box.offset(0, 1, 0)))
return;
@ -106,6 +97,14 @@ public final class StepHack extends Hack implements UpdateListener
player.getZ());
}
public float adjustStepHeight(float stepHeight)
{
if(isEnabled() && mode.getSelected() == Mode.SIMPLE)
return height.getValueF();
return stepHeight;
}
public boolean isAutoJumpAllowed()
{
return !isEnabled() && !WURST.getCmds().goToCmd.isActive();

View File

@ -7,13 +7,19 @@
*/
package net.wurstclient.hacks;
import java.util.ArrayList;
import java.util.Optional;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.PotionContentsComponent;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.text.Text;
import net.wurstclient.Category;
import net.wurstclient.SearchTags;
@ -104,25 +110,24 @@ public final class TrollPotionHack extends Hack
{
ItemStack stack = new ItemStack(item);
NbtList effects = new NbtList();
ArrayList<StatusEffectInstance> effects = new ArrayList<>();
for(int i = 1; i <= 23; i++)
{
String id = Registries.STATUS_EFFECT.getEntry(i).get().getKey()
.get().getValue().toString();
StatusEffect effect =
Registries.STATUS_EFFECT.getEntry(i).get().value();
RegistryEntry<StatusEffect> entry =
Registries.STATUS_EFFECT.getEntry(effect);
NbtCompound effect = new NbtCompound();
effect.putInt("amplifier", Integer.MAX_VALUE);
effect.putInt("duration", Integer.MAX_VALUE);
effect.putString("id", id);
effects.add(effect);
effects.add(new StatusEffectInstance(entry, Integer.MAX_VALUE,
Integer.MAX_VALUE));
}
NbtCompound nbt = new NbtCompound();
nbt.put("custom_potion_effects", effects);
stack.setNbt(nbt);
stack.set(DataComponentTypes.POTION_CONTENTS,
new PotionContentsComponent(Optional.empty(), Optional.empty(),
effects));
String name = "\u00a7f" + itemName + " of Trolling";
stack.setCustomName(Text.literal(name));
stack.set(DataComponentTypes.CUSTOM_NAME, Text.literal(name));
return stack;
}

View File

@ -713,7 +713,6 @@ public final class TunnellerHack extends Hack
private class PlaceTorchTask extends Task
{
@SuppressWarnings("deprecation")
@Override
public boolean canRun()
{
@ -755,10 +754,9 @@ public final class TunnellerHack extends Hack
BlockState state = BlockUtils.getState(nextTorch);
if(!state.isReplaceable())
return false;
// Can't see why canPlaceAt() is deprecated. Still seems to be
// widely used with no replacement.
return Blocks.TORCH.canPlaceAt(state, MC.world, nextTorch);
return Blocks.TORCH.getDefaultState().canPlaceAt(MC.world,
nextTorch);
}
@Override

View File

@ -42,12 +42,12 @@ public final class XRayHack extends Hack implements UpdateListener,
"A list of blocks that X-Ray will show. They don't have to be just ores"
+ " - you can add any block you want.\n\n"
+ "Remember to restart X-Ray when changing this setting.",
"minecraft:ancient_debris", "minecraft:anvil", "minecraft:beacon",
"minecraft:bone_block", "minecraft:bookshelf",
"minecraft:brewing_stand", "minecraft:chain_command_block",
"minecraft:chest", "minecraft:clay", "minecraft:coal_block",
"minecraft:coal_ore", "minecraft:command_block", "minecraft:copper_ore",
"minecraft:crafter", "minecraft:crafting_table",
"minecraft:amethyst_cluster", "minecraft:ancient_debris",
"minecraft:anvil", "minecraft:beacon", "minecraft:bone_block",
"minecraft:bookshelf", "minecraft:brewing_stand",
"minecraft:chain_command_block", "minecraft:chest", "minecraft:clay",
"minecraft:coal_block", "minecraft:coal_ore", "minecraft:command_block",
"minecraft:copper_ore", "minecraft:crafter", "minecraft:crafting_table",
"minecraft:decorated_pot", "minecraft:deepslate_coal_ore",
"minecraft:deepslate_copper_ore", "minecraft:deepslate_diamond_ore",
"minecraft:deepslate_emerald_ore", "minecraft:deepslate_gold_ore",
@ -68,7 +68,8 @@ public final class XRayHack extends Hack implements UpdateListener,
"minecraft:redstone_ore", "minecraft:repeating_command_block",
"minecraft:spawner", "minecraft:suspicious_gravel",
"minecraft:suspicious_sand", "minecraft:tnt", "minecraft:torch",
"minecraft:trapped_chest", "minecraft:water");
"minecraft:trapped_chest", "minecraft:trial_spawner", "minecraft:vault",
"minecraft:water");
private final CheckboxSetting onlyExposed = new CheckboxSetting(
"Only show exposed",

View File

@ -10,6 +10,7 @@ package net.wurstclient.hacks.autocomplete;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import com.google.gson.JsonArray;
@ -50,7 +51,8 @@ public final class OobaboogaMessageCompleter extends MessageCompleter
throws IOException, JsonException
{
// set up the API request
URL url = new URL(modelSettings.oobaboogaEndpoint.getValue());
URL url =
URI.create(modelSettings.oobaboogaEndpoint.getValue()).toURL();
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");

View File

@ -10,6 +10,7 @@ package net.wurstclient.hacks.autocomplete;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import com.google.gson.JsonArray;
@ -64,9 +65,10 @@ public final class OpenAiMessageCompleter extends MessageCompleter
throws IOException, JsonException
{
// get the API URL
URL url = modelSettings.openAiModel.getSelected().isChatModel()
? new URL(modelSettings.openaiChatEndpoint.getValue())
: new URL(modelSettings.openaiLegacyEndpoint.getValue());
URL url =
URI.create(modelSettings.openAiModel.getSelected().isChatModel()
? modelSettings.openaiChatEndpoint.getValue()
: modelSettings.openaiLegacyEndpoint.getValue()).toURL();
// set up the API request
HttpURLConnection conn = (HttpURLConnection)url.openConnection();

View File

@ -13,9 +13,9 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.google.common.collect.ImmutableMap;
import com.mojang.serialization.MapCodec;
import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap;
import net.minecraft.block.AbstractBlock.AbstractBlockState;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -37,11 +37,11 @@ import net.wurstclient.hacks.HandNoClipHack;
@Mixin(AbstractBlockState.class)
public abstract class AbstractBlockStateMixin extends State<Block, BlockState>
{
private AbstractBlockStateMixin(WurstClient wurst, Block object,
ImmutableMap<Property<?>, Comparable<?>> immutableMap,
MapCodec<BlockState> mapCodec)
private AbstractBlockStateMixin(WurstClient wurst, Block owner,
Reference2ObjectArrayMap<Property<?>, Comparable<?>> propertyMap,
MapCodec<BlockState> codec)
{
super(object, immutableMap, mapCodec);
super(owner, propertyMap, codec);
}
@Inject(at = @At("TAIL"),

View File

@ -17,7 +17,9 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.MinecraftClient;
import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.gui.hud.ChatHudLine;
import net.minecraft.client.gui.hud.MessageIndicator;
@ -33,16 +35,14 @@ public class ChatHudMixin
@Shadow
@Final
private List<ChatHudLine.Visible> visibleMessages;
@Shadow
@Final
private MinecraftClient client;
@Inject(at = @At("HEAD"),
method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V",
cancellable = true)
private void onAddMessage(Text message,
@Nullable MessageSignatureData signature,
@Nullable MessageIndicator indicator, CallbackInfo ci)
@Nullable MessageIndicator indicatorDontUse, CallbackInfo ci,
@Local LocalRef<MessageIndicator> indicator)
{
ChatInputEvent event = new ChatInputEvent(message, visibleMessages);
@ -54,28 +54,7 @@ public class ChatHudMixin
}
message = event.getComponent();
indicator = WurstClient.INSTANCE.getOtfs().noChatReportsOtf
.modifyIndicator(message, signature, indicator);
shadow$logChatMessage(message, indicator);
shadow$addMessage(message, signature, client.inGameHud.getTicks(),
indicator, false);
ci.cancel();
}
@Shadow
private void shadow$logChatMessage(Text message,
@Nullable MessageIndicator indicator)
{
}
@Shadow
private void shadow$addMessage(Text message,
@Nullable MessageSignatureData signature, int ticks,
@Nullable MessageIndicator indicator, boolean refresh)
{
indicator.set(WurstClient.INSTANCE.getOtfs().noChatReportsOtf
.modifyIndicator(message, signature, indicator.get()));
}
}

View File

@ -12,7 +12,6 @@ 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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.gui.screen.Screen;
@ -41,10 +40,10 @@ public abstract class ChatScreenMixin extends Screen
}
@Inject(at = @At("HEAD"),
method = "sendMessage(Ljava/lang/String;Z)Z",
method = "sendMessage(Ljava/lang/String;Z)V",
cancellable = true)
public void onSendMessage(String message, boolean addToHistory,
CallbackInfoReturnable<Boolean> cir)
CallbackInfo ci)
{
// Ignore empty messages just like vanilla
if((message = normalize(message)).isEmpty())
@ -61,7 +60,7 @@ public abstract class ChatScreenMixin extends Screen
return;
// Otherwise, cancel the vanilla method and handle the message here
cir.setReturnValue(true);
ci.cancel();
// Add the message to history, even if it was cancelled
// Otherwise the up/down arrows won't work correctly

View File

@ -23,7 +23,7 @@ import net.minecraft.network.listener.TickablePacketListener;
import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket;
import net.minecraft.network.packet.s2c.play.ChunkData;
import net.minecraft.network.packet.s2c.play.ChunkDeltaUpdateS2CPacket;
import net.minecraft.network.packet.s2c.play.ServerMetadataS2CPacket;
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.wurstclient.WurstClient;
@ -42,16 +42,15 @@ public abstract class ClientPlayNetworkHandlerMixin
}
@Inject(at = @At("TAIL"),
method = "onServerMetadata(Lnet/minecraft/network/packet/s2c/play/ServerMetadataS2CPacket;)V")
public void onOnServerMetadata(ServerMetadataS2CPacket packet,
CallbackInfo ci)
method = "onGameJoin(Lnet/minecraft/network/packet/s2c/play/GameJoinS2CPacket;)V")
public void onOnGameJoin(GameJoinS2CPacket packet, CallbackInfo ci)
{
WurstClient wurst = WurstClient.INSTANCE;
if(!wurst.isEnabled())
return;
// Remove Mojang's dishonest warning toast on safe servers
if(!packet.isSecureChatEnforced())
if(!packet.enforcesSecureChat())
{
client.getToastManager().toastQueue.removeIf(toast -> toast
.getType() == SystemToast.Type.UNSECURE_SERVER_WARNING);

View File

@ -29,6 +29,7 @@ import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.MovementType;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.math.Vec3d;
import net.wurstclient.WurstClient;
import net.wurstclient.event.EventManager;
@ -289,7 +290,7 @@ public class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
}
@Override
public boolean hasStatusEffect(StatusEffect effect)
public boolean hasStatusEffect(RegistryEntry<StatusEffect> effect)
{
HackList hax = WurstClient.INSTANCE.getHax();
@ -306,4 +307,33 @@ public class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
return super.hasStatusEffect(effect);
}
@Override
public float getStepHeight()
{
return WurstClient.INSTANCE.getHax().stepHack
.adjustStepHeight(super.getStepHeight());
}
// getter for GENERIC_BLOCK_INTERACTION_RANGE
@Override
public double getBlockInteractionRange()
{
HackList hax = WurstClient.INSTANCE.getHax();
if(hax == null || !hax.reachHack.isEnabled())
return super.getBlockInteractionRange();
return hax.reachHack.getReachDistance();
}
// getter for GENERIC_ENTITY_INTERACTION_RANGE
@Override
public double getEntityInteractionRange()
{
HackList hax = WurstClient.INSTANCE.getHax();
if(hax == null || !hax.reachHack.isEnabled())
return super.getEntityInteractionRange();
return hax.reachHack.getReachDistance();
}
}

View File

@ -31,12 +31,9 @@ import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.wurstclient.WurstClient;
import net.wurstclient.event.EventManager;
import net.wurstclient.events.BlockBreakingProgressListener.BlockBreakingProgressEvent;
import net.wurstclient.events.StopUsingItemListener.StopUsingItemEvent;
import net.wurstclient.hack.HackList;
import net.wurstclient.hacks.ReachHack;
import net.wurstclient.mixinterface.IClientPlayerInteractionManager;
@Mixin(ClientPlayerInteractionManager.class)
@ -57,32 +54,6 @@ public abstract class ClientPlayerInteractionManagerMixin
EventManager.fire(new BlockBreakingProgressEvent(pos, direction));
}
@Inject(at = @At("HEAD"),
method = "getReachDistance()F",
cancellable = true)
private void onGetReachDistance(CallbackInfoReturnable<Float> ci)
{
HackList hax = WurstClient.INSTANCE.getHax();
if(hax == null)
return;
ReachHack reach = hax.reachHack;
if(reach.isEnabled())
ci.setReturnValue(reach.getReachDistance());
}
@Inject(at = @At("HEAD"),
method = "hasExtendedReach()Z",
cancellable = true)
private void hasExtendedReach(CallbackInfoReturnable<Boolean> cir)
{
HackList hax = WurstClient.INSTANCE.getHax();
if(hax == null || !hax.reachHack.isEnabled())
return;
cir.setReturnValue(true);
}
@Inject(at = @At("HEAD"),
method = "stopUsingItem(Lnet/minecraft/entity/player/PlayerEntity;)V")
private void onStopUsingItem(PlayerEntity player, CallbackInfo ci)

View File

@ -35,11 +35,11 @@ public abstract class EntityRendererMixin<T extends Entity>
protected EntityRenderDispatcher dispatcher;
@Inject(at = @At("HEAD"),
method = "renderLabelIfPresent(Lnet/minecraft/entity/Entity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
method = "renderLabelIfPresent(Lnet/minecraft/entity/Entity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IF)V",
cancellable = true)
private void onRenderLabelIfPresent(T entity, Text text,
MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider,
int i, CallbackInfo ci)
int i, float tickDelta, CallbackInfo ci)
{
// add HealthTags info
if(entity instanceof LivingEntity)
@ -48,7 +48,7 @@ public abstract class EntityRendererMixin<T extends Entity>
// do NameTags adjustments
wurstRenderLabelIfPresent(entity, text, matrixStack,
vertexConsumerProvider, i);
vertexConsumerProvider, i, tickDelta);
ci.cancel();
}
@ -57,7 +57,8 @@ public abstract class EntityRendererMixin<T extends Entity>
* an infinite loop. Also makes it easier to modify.
*/
protected void wurstRenderLabelIfPresent(T entity, Text text,
MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light)
MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light,
float tickDelta)
{
NameTagsHack nameTags = WurstClient.INSTANCE.getHax().nameTagsHack;

View File

@ -77,6 +77,8 @@ public abstract class GameMenuScreenMixin extends Screen
float u = 0;
float v = 0;
context.drawTexture(WURST_TEXTURE, x, y, u, v, w, h, fw, fh);
GL11.glDisable(GL11.GL_BLEND);
}
private void addWurstOptionsButton()

View File

@ -7,23 +7,27 @@
*/
package net.wurstclient.mixin;
import org.joml.Matrix4f;
import org.objectweb.asm.Opcodes;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.hit.HitResult;
import net.wurstclient.WurstClient;
import net.wurstclient.event.EventManager;
import net.wurstclient.events.CameraTransformViewBobbingListener.CameraTransformViewBobbingEvent;
import net.wurstclient.events.HitResultRayTraceListener.HitResultRayTraceEvent;
import net.wurstclient.events.RenderListener.RenderEvent;
import net.wurstclient.hacks.FullbrightHack;
@ -38,10 +42,9 @@ public abstract class GameRendererMixin implements AutoCloseable
*/
@Inject(at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/render/GameRenderer;bobView(Lnet/minecraft/client/util/math/MatrixStack;F)V",
ordinal = 0),
method = "renderWorld(FJLnet/minecraft/client/util/math/MatrixStack;)V")
ordinal = 0), method = "renderWorld(FJ)V")
private void onRenderWorldViewBobbing(float tickDelta, long limitTime,
MatrixStack matrices, CallbackInfo ci)
CallbackInfo ci)
{
CameraTransformViewBobbingEvent event =
new CameraTransformViewBobbingEvent();
@ -74,9 +77,9 @@ public abstract class GameRendererMixin implements AutoCloseable
* after the view-bobbing call.
*/
@Inject(at = @At("HEAD"),
method = "renderHand(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/Camera;F)V")
private void onRenderHand(MatrixStack matrices, Camera camera,
float tickDelta, CallbackInfo ci)
method = "renderHand(Lnet/minecraft/client/render/Camera;FLorg/joml/Matrix4f;)V")
private void onRenderHand(Camera camera, float tickDelta, Matrix4f matrix4f,
CallbackInfo ci)
{
cancelNextBobView = false;
}
@ -86,11 +89,13 @@ public abstract class GameRendererMixin implements AutoCloseable
target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z",
opcode = Opcodes.GETFIELD,
ordinal = 0),
method = "renderWorld(FJLnet/minecraft/client/util/math/MatrixStack;)V")
private void onRenderWorld(float tickDelta, long limitTime,
MatrixStack matrices, CallbackInfo ci)
method = "renderWorld(FJ)V")
private void onRenderWorld(float tickDelta, long limitTime, CallbackInfo ci,
@Local(ordinal = 1) Matrix4f matrix4f2)
{
RenderEvent event = new RenderEvent(matrices, tickDelta);
MatrixStack matrixStack = new MatrixStack();
matrixStack.multiplyPositionMatrix(matrix4f2);
RenderEvent event = new RenderEvent(matrixStack, tickDelta);
EventManager.fire(event);
}
@ -104,25 +109,33 @@ public abstract class GameRendererMixin implements AutoCloseable
.changeFovBasedOnZoom(cir.getReturnValueD()));
}
@Inject(at = @At(value = "INVOKE",
target = "Lnet/minecraft/entity/Entity;getCameraPosVec(F)Lnet/minecraft/util/math/Vec3d;",
opcode = Opcodes.INVOKEVIRTUAL,
ordinal = 0), method = "updateTargetedEntity(F)V")
private void onHitResultRayTrace(float tickDelta, CallbackInfo ci)
/**
* This is the part that makes Liquids work.
*/
@WrapOperation(at = @At(value = "INVOKE",
target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;",
ordinal = 0),
method = "findCrosshairTarget(Lnet/minecraft/entity/Entity;DDF)Lnet/minecraft/util/hit/HitResult;")
private HitResult liquidsRaycast(Entity instance, double maxDistance,
float tickDelta, boolean includeFluids, Operation<HitResult> original)
{
HitResultRayTraceEvent event = new HitResultRayTraceEvent(tickDelta);
EventManager.fire(event);
if(!WurstClient.INSTANCE.getHax().liquidsHack.isEnabled())
return original.call(instance, maxDistance, tickDelta,
includeFluids);
return original.call(instance, maxDistance, tickDelta, true);
}
@Redirect(
@WrapOperation(
at = @At(value = "INVOKE",
target = "Lnet/minecraft/util/math/MathHelper;lerp(FFF)F",
ordinal = 0),
method = "renderWorld(FJLnet/minecraft/client/util/math/MatrixStack;)V")
private float wurstNauseaLerp(float delta, float start, float end)
method = "renderWorld(FJ)V")
private float wurstNauseaLerp(float delta, float start, float end,
Operation<Float> original)
{
if(!WurstClient.INSTANCE.getHax().antiWobbleHack.isEnabled())
return MathHelper.lerp(delta, start, end);
return original.call(delta, start, end);
return 0;
}

View File

@ -29,13 +29,12 @@ public class IngameHudMixin
@Final
private DebugHud debugHud;
@Inject(
at = @At(value = "INVOKE",
target = "Lcom/mojang/blaze3d/systems/RenderSystem;enableBlend()V",
remap = false,
ordinal = 3),
method = "render(Lnet/minecraft/client/gui/DrawContext;F)V")
private void onRender(DrawContext context, float tickDelta, CallbackInfo ci)
// runs after renderScoreboardSidebar()
// and before playerListHud.setVisible()
@Inject(at = @At("HEAD"),
method = "renderPlayerList(Lnet/minecraft/client/gui/DrawContext;F)V")
private void onRenderPlayerList(DrawContext context, float tickDelta,
CallbackInfo ci)
{
if(debugHud.shouldShowDebugHud())
return;

View File

@ -8,13 +8,13 @@
package net.wurstclient.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
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.api.client.screen.v1.Screens;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.StatsListener;
import net.minecraft.client.gui.screen.StatsScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.ClickableWidget;
@ -23,8 +23,11 @@ import net.minecraft.text.Text;
import net.wurstclient.WurstClient;
@Mixin(StatsScreen.class)
public abstract class StatsScreenMixin extends Screen implements StatsListener
public abstract class StatsScreenMixin extends Screen
{
@Unique
private ButtonWidget toggleWurstButton;
private StatsScreenMixin(WurstClient wurst, Text title)
{
super(title);
@ -36,24 +39,39 @@ public abstract class StatsScreenMixin extends Screen implements StatsListener
if(WurstClient.INSTANCE.getOtfs().disableOtf.shouldHideEnableButton())
return;
ButtonWidget toggleWurstButton =
ButtonWidget.builder(Text.literal(""), this::toggleWurst)
.dimensions(width / 2 - 152, height - 28, 150, 20).build();
toggleWurstButton = ButtonWidget
.builder(Text.literal(""), this::toggleWurst).width(150).build();
updateWurstButtonText(toggleWurstButton);
addDrawableChild(toggleWurstButton);
for(ClickableWidget button : Screens.getButtons(this))
{
if(!button.getMessage().getString()
.equals(I18n.translate("gui.done")))
continue;
button.setX(width / 2 + 2);
button.setWidth(150);
}
}
@Inject(at = @At("TAIL"), method = "initTabNavigation()V")
private void onInitTabNavigation(CallbackInfo ci)
{
if(toggleWurstButton == null)
return;
ClickableWidget doneButton = wurst_getDoneButton();
doneButton.setX(width / 2 + 2);
doneButton.setWidth(150);
toggleWurstButton.setPosition(width / 2 - 152, doneButton.getY());
}
@Unique
private ClickableWidget wurst_getDoneButton()
{
for(ClickableWidget button : Screens.getButtons(this))
if(button.getMessage().getString()
.equals(I18n.translate("gui.done")))
return button;
throw new IllegalStateException(
"Can't find the done button on the statistics screen.");
}
@Unique
private void toggleWurst(ButtonWidget button)
{
WurstClient wurst = WurstClient.INSTANCE;
@ -62,6 +80,7 @@ public abstract class StatsScreenMixin extends Screen implements StatsListener
updateWurstButtonText(button);
}
@Unique
private void updateWurstButtonText(ButtonWidget button)
{
WurstClient wurst = WurstClient.INSTANCE;

View File

@ -41,7 +41,7 @@ public class WurstServerPinger
try
{
pinger.add(server, () -> {});
pinger.add(server, () -> {}, () -> {});
System.out.println("Ping successful: " + ip + ":" + port);
}catch(UnknownHostException e)

View File

@ -12,6 +12,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
@ -69,7 +70,7 @@ public enum GoogleTranslate
"https://translate.google.com/m?hl=en&sl=%s&tl=%s&ie=UTF-8&prev=_m&q=%s",
langFrom, langTo, encodedText);
return new URL(urlString);
return URI.create(urlString).toURL();
}catch(MalformedURLException | UnsupportedEncodingException e)
{

View File

@ -7,16 +7,18 @@
*/
package net.wurstclient.util;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.attribute.EntityAttributes;
import java.util.OptionalDouble;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.AttributeModifiersComponent;
import net.minecraft.component.type.PotionContentsComponent;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException;
@ -55,32 +57,28 @@ public enum ItemUtils
}
}
public static float getAttackSpeed(Item item)
public static OptionalDouble getAttribute(Item item,
RegistryEntry<EntityAttribute> attribute)
{
return (float)item.getAttributeModifiers(EquipmentSlot.MAINHAND)
.get(EntityAttributes.GENERIC_ATTACK_SPEED).stream().findFirst()
.orElseThrow().getValue();
return item.getComponents()
.getOrDefault(DataComponentTypes.ATTRIBUTE_MODIFIERS,
AttributeModifiersComponent.DEFAULT)
.modifiers().stream()
.filter(modifier -> modifier.attribute() == attribute)
.mapToDouble(modifier -> modifier.modifier().value()).findFirst();
}
/**
* Adds the specified enchantment to the specified item stack. Unlike
* {@link ItemStack#addEnchantment(Enchantment, int)}, this method doesn't
* limit the level to 127.
*/
public static void addEnchantment(ItemStack stack, Enchantment enchantment,
int level)
public static boolean hasEffect(ItemStack stack,
RegistryEntry<StatusEffect> effect)
{
Identifier id = EnchantmentHelper.getEnchantmentId(enchantment);
NbtList nbt = getOrCreateNbtList(stack, ItemStack.ENCHANTMENTS_KEY);
nbt.add(EnchantmentHelper.createNbt(id, level));
}
public static NbtList getOrCreateNbtList(ItemStack stack, String key)
{
NbtCompound nbt = stack.getOrCreateNbt();
if(!nbt.contains(key, NbtElement.LIST_TYPE))
nbt.put(key, new NbtList());
PotionContentsComponent potionContents = stack.getComponents()
.getOrDefault(DataComponentTypes.POTION_CONTENTS,
PotionContentsComponent.DEFAULT);
return nbt.getList(key, NbtElement.COMPOUND_TYPE);
for(StatusEffectInstance effectInstance : potionContents.getEffects())
if(effectInstance.getEffectType() == effect)
return true;
return false;
}
}

View File

@ -49,6 +49,6 @@ public enum LastServerRememberer
return;
ConnectScreen.connect(prevScreen, WurstClient.MC,
ServerAddress.parse(lastServer.address), lastServer, false);
ServerAddress.parse(lastServer.address), lastServer, false, null);
}
}

View File

@ -21,18 +21,21 @@ import net.minecraft.client.gui.AbstractParentElement;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
public abstract class ListWidget extends AbstractParentElement
implements Drawable
{
private static final Identifier MENU_LIST_BACKGROUND_TEXTURE =
new Identifier("textures/gui/menu_list_background.png");
protected final MinecraftClient client;
protected int width;
protected int height;
@ -144,7 +147,8 @@ public abstract class ListWidget extends AbstractParentElement
capYPosition();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.setShaderTexture(0, Screen.OPTIONS_BACKGROUND_TEXTURE);
RenderSystem.enableBlend();
RenderSystem.setShaderTexture(0, MENU_LIST_BACKGROUND_TEXTURE);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShader(GameRenderer::getPositionTexColorProgram);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS,
@ -167,7 +171,9 @@ public abstract class ListWidget extends AbstractParentElement
if(renderHeader)
renderHeader(k, l, tessellator);
context.enableScissor(left, top, right, bottom);
renderList(context, k, l, mouseX, mouseY, delta);
context.disableScissor();
RenderSystem.disableDepthTest();
renderHoleBackground(0, top, 255, 255);
renderHoleBackground(bottom, height, 255, 255);
@ -175,9 +181,6 @@ public abstract class ListWidget extends AbstractParentElement
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA,
GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA,
GlStateManager.SrcFactor.ZERO, GlStateManager.DstFactor.ONE);
// RenderSystem.disableAlphaTest();
// RenderSystem.shadeModel(7425);
// RenderSystem.disableTexture();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION_TEXTURE_COLOR);
@ -246,9 +249,6 @@ public abstract class ListWidget extends AbstractParentElement
}
renderDecorations(mouseX, mouseY);
// RenderSystem.enableTexture();
// RenderSystem.shadeModel(7424);
// RenderSystem.enableAlphaTest();
RenderSystem.disableBlend();
}
}
@ -392,7 +392,6 @@ public abstract class ListWidget extends AbstractParentElement
{
int q = left + width / 2 - getRowWidth() / 2;
int r = left + width / 2 + getRowWidth() / 2;
// RenderSystem.disableTexture();
float g = isFocused() ? 1.0F : 0.5F;
RenderSystem.setShaderColor(g, g, g, 1.0F);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS,
@ -410,7 +409,6 @@ public abstract class ListWidget extends AbstractParentElement
bufferBuilder.vertex(r - 1, o - 1, 0.0D).next();
bufferBuilder.vertex(q + 1, o - 1, 0.0D).next();
tessellator.draw();
// RenderSystem.enableTexture();
}
RenderSystem.setShaderColor(1, 1, 1, 1);
@ -435,7 +433,8 @@ public abstract class ListWidget extends AbstractParentElement
{
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.setShaderTexture(0, Screen.OPTIONS_BACKGROUND_TEXTURE);
RenderSystem.enableBlend();
RenderSystem.setShaderTexture(0, MENU_LIST_BACKGROUND_TEXTURE);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShader(GameRenderer::getPositionTexColorProgram);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS,

View File

@ -30,9 +30,9 @@
"depends": {
"fabricloader": ">=0.15.9",
"fabric-api": ">=0.91.1",
"minecraft": "~1.20.3-beta.3",
"java": ">=17"
"fabric-api": ">=0.97.1",
"minecraft": "~1.20.5-alpha.24.13.a",
"java": ">=21"
},
"suggests": {
"mo_glass": "*"

View File

@ -18,6 +18,4 @@ accessible field net/minecraft/client/network/ClientPlayerInteractionManager bre
accessible field net/minecraft/client/network/ClientPlayerInteractionManager currentBreakingProgress F
accessible field net/minecraft/client/toast/ToastManager toastQueue Ljava/util/Deque;
accessible field net/minecraft/entity/Entity movementMultiplier Lnet/minecraft/util/math/Vec3d;
accessible field net/minecraft/entity/Entity stepHeight F
accessible field net/minecraft/item/ArmorItem toughness F
accessible field net/minecraft/network/packet/s2c/play/ChunkDeltaUpdateS2CPacket sectionPos Lnet/minecraft/util/math/ChunkSectionPos;