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

Update to 24w36a

This commit is contained in:
Alexander01998 2024-09-05 19:19:23 +02:00
parent 73b1e8aec9
commit 1d2cbab405
8 changed files with 116 additions and 59 deletions

View File

@ -673,6 +673,7 @@ public final class AltManagerScreen extends Screen
}
// face
context.draw();
AltRenderer.drawAltFace(context, alt.getName(), x + 1, y + 1, 24,
24, isSelectedItem(id));

View File

@ -10,6 +10,7 @@ package net.wurstclient.hacks;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumMap;
import java.util.Optional;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
@ -18,10 +19,9 @@ import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.AnimalArmorItem;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorItem.Type;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket;
import net.minecraft.registry.DynamicRegistryManager;
@ -37,6 +37,8 @@ import net.wurstclient.hack.Hack;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.SliderSetting;
import net.wurstclient.settings.SliderSetting.ValueDisplay;
import net.wurstclient.util.InventoryUtils;
import net.wurstclient.util.ItemUtils;
@SearchTags({"auto armor"})
public final class AutoArmorHack extends Hack
@ -106,20 +108,22 @@ public final class AutoArmorHack extends Hack
return;
// store slots and values of best armor pieces
int[] bestArmorSlots = new int[4];
int[] bestArmorValues = new int[4];
EnumMap<EquipmentSlot, ArmorData> bestArmor =
new EnumMap<>(EquipmentSlot.class);
ArrayList<EquipmentSlot> armorTypes =
new ArrayList<>(Arrays.asList(EquipmentSlot.FEET,
EquipmentSlot.LEGS, EquipmentSlot.CHEST, EquipmentSlot.HEAD));
// initialize with currently equipped armor
for(int type = 0; type < 4; type++)
for(EquipmentSlot type : armorTypes)
{
bestArmorSlots[type] = -1;
bestArmor.put(type, new ArmorData(-1, 0));
ItemStack stack = inventory.getArmorStack(type);
if(!(stack.getItem() instanceof ArmorItem item)
|| item instanceof AnimalArmorItem)
ItemStack stack = inventory.getArmorStack(type.getEntitySlotId());
if(!MC.player.canEquip(stack, type))
continue;
bestArmorValues[type] = getArmorValue(item, stack);
bestArmor.put(type, new ArmorData(-1, getArmorValue(stack)));
}
// search inventory for better armor
@ -127,44 +131,38 @@ public final class AutoArmorHack extends Hack
{
ItemStack stack = inventory.getStack(slot);
if(!(stack.getItem() instanceof ArmorItem item)
|| item instanceof AnimalArmorItem)
EquipmentSlot armorType = ItemUtils.getArmorSlot(stack.getItem());
if(armorType == null)
continue;
int armorType = item.getSlotType().getEntitySlotId();
int armorValue = getArmorValue(item, stack);
int armorValue = getArmorValue(stack);
if(armorValue > bestArmorValues[armorType])
{
bestArmorSlots[armorType] = slot;
bestArmorValues[armorType] = armorValue;
}
if(armorValue > bestArmor.get(armorType).armorValue())
bestArmor.put(armorType, new ArmorData(slot, armorValue));
}
// equip better armor in random order
ArrayList<Integer> types = new ArrayList<>(Arrays.asList(0, 1, 2, 3));
Collections.shuffle(types);
for(int type : types)
Collections.shuffle(armorTypes);
for(EquipmentSlot type : armorTypes)
{
// check if better armor was found
int slot = bestArmorSlots[type];
if(slot == -1)
ArmorData data = bestArmor.get(type);
if(data.invSlot() == -1)
continue;
// check if armor can be swapped
// needs 1 free slot where it can put the old armor
ItemStack oldArmor = inventory.getArmorStack(type);
ItemStack oldArmor =
inventory.getArmorStack(type.getEntitySlotId());
if(!oldArmor.isEmpty() && inventory.getEmptySlot() == -1)
continue;
// hotbar fix
if(slot < 9)
slot += 36;
// swap armor
if(!oldArmor.isEmpty())
IMC.getInteractionManager().windowClick_QUICK_MOVE(8 - type);
IMC.getInteractionManager().windowClick_QUICK_MOVE(slot);
IMC.getInteractionManager()
.windowClick_QUICK_MOVE(8 - type.getEntitySlotId());
IMC.getInteractionManager().windowClick_QUICK_MOVE(
InventoryUtils.toNetworkSlot(data.invSlot()));
break;
}
@ -177,12 +175,12 @@ public final class AutoArmorHack extends Hack
timer = delay.getValueI();
}
private int getArmorValue(ArmorItem item, ItemStack stack)
private int getArmorValue(ItemStack stack)
{
int armorPoints = item.getProtection();
Item item = stack.getItem();
int armorPoints = (int)ItemUtils.getArmorPoints(item);
int prtPoints = 0;
int armorToughness = (int)item.getToughness();
int armorType = item.getMaterial().value().getProtection(Type.LEGGINGS);
int armorToughness = (int)ItemUtils.getToughness(item);
if(useEnchantments.isChecked())
{
@ -193,20 +191,14 @@ public final class AutoArmorHack extends Hack
Optional<Reference<Enchantment>> protection =
registry.getOptional(Enchantments.PROTECTION);
int prtLvl = protection
prtPoints = protection
.map(entry -> EnchantmentHelper.getLevel(entry, stack))
.orElse(0);
// ClientPlayerEntity player = MC.player;
// DamageSource dmgSource =
// player.getDamageSources().playerAttack(player);
// prtPoints = protection.getProtectionAmount(prtLvl, dmgSource);
// Only the server can calculate protection amount as of
// 24w18a (1.21). Related bug: MC-196250
prtPoints = prtLvl;
}
return armorPoints * 5 + prtPoints * 3 + armorToughness + armorType;
return armorPoints * 5 + prtPoints * 3 + armorToughness;
}
private record ArmorData(int invSlot, int armorValue)
{}
}

View File

@ -7,10 +7,6 @@
*/
package net.wurstclient.hacks;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ElytraItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
@ -71,8 +67,7 @@ public final class ExtraElytraHack extends Hack implements UpdateListener
if(jumpTimer > 0)
jumpTimer--;
ItemStack chest = MC.player.getEquippedStack(EquipmentSlot.CHEST);
if(chest.getItem() != Items.ELYTRA)
if(!MC.player.canGlide())
return;
if(MC.player.isGliding())
@ -88,7 +83,7 @@ public final class ExtraElytraHack extends Hack implements UpdateListener
return;
}
if(ElytraItem.isUsable(chest) && MC.options.jumpKey.isPressed())
if(MC.options.jumpKey.isPressed())
doInstantFly();
}

View File

@ -68,7 +68,7 @@ public final class StepHack extends Hack implements UpdateListener
&& player.input.movementSideways == 0)
return;
if(player.input.jumping)
if(player.jumping)
return;
Box box = player.getBoundingBox().offset(0, 0.05, 0).expand(0.05);

View File

@ -130,7 +130,7 @@ public final class TabGui implements KeyPressListener
return;
// CURSED: TabGUI renders behind HackList without this
context.getVertexConsumers().draw();
context.draw();
ClickGui gui = WurstClient.INSTANCE.getGui();
int txtColor = gui.getTxtColor();

View File

@ -9,10 +9,14 @@ package net.wurstclient.util;
import java.util.OptionalDouble;
import net.minecraft.client.MinecraftClient;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.AttributeModifiersComponent;
import net.minecraft.component.type.EquippableComponent;
import net.minecraft.component.type.PotionContentsComponent;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.item.Item;
@ -21,11 +25,14 @@ import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException;
import net.wurstclient.WurstClient;
public enum ItemUtils
{
;
private static final MinecraftClient MC = WurstClient.MC;
/**
* @param nameOrId
* a String containing the item's name ({@link Identifier}) or
@ -57,6 +64,8 @@ public enum ItemUtils
}
}
// TODO: Update AutoSword to use calculateModifiedAttribute() instead,
// then remove this method.
public static OptionalDouble getAttribute(Item item,
RegistryEntry<EntityAttribute> attribute)
{
@ -68,6 +77,64 @@ public enum ItemUtils
.mapToDouble(modifier -> modifier.modifier().value()).findFirst();
}
public static double calculateModifiedAttribute(Item item,
RegistryEntry<EntityAttribute> attribute, double base,
EquipmentSlot slot)
{
AttributeModifiersComponent modifiers = item.getComponents()
.getOrDefault(DataComponentTypes.ATTRIBUTE_MODIFIERS,
AttributeModifiersComponent.DEFAULT);
double result = base;
for(AttributeModifiersComponent.Entry entry : modifiers.modifiers())
{
if(entry.attribute() != attribute || !entry.slot().matches(slot))
continue;
double value = entry.modifier().value();
result += switch(entry.modifier().operation())
{
case ADD_VALUE -> value;
case ADD_MULTIPLIED_BASE -> value * base;
case ADD_MULTIPLIED_TOTAL -> value * result;
};
}
return result;
}
public static double getArmorAttribute(Item item,
RegistryEntry<EntityAttribute> attribute)
{
EquippableComponent equippable =
item.getComponents().get(DataComponentTypes.EQUIPPABLE);
double base = MC.player.getAttributeBaseValue(attribute);
if(equippable == null)
return base;
return calculateModifiedAttribute(item, attribute, base,
equippable.slot());
}
public static double getArmorPoints(Item item)
{
return getArmorAttribute(item, EntityAttributes.ARMOR);
}
public static double getToughness(Item item)
{
return getArmorAttribute(item, EntityAttributes.ARMOR_TOUGHNESS);
}
public static EquipmentSlot getArmorSlot(Item item)
{
EquippableComponent equippable =
item.getComponents().get(DataComponentTypes.EQUIPPABLE);
return equippable != null ? equippable.slot() : null;
}
public static boolean hasEffect(ItemStack stack,
RegistryEntry<StatusEffect> effect)
{

View File

@ -26,8 +26,8 @@
"accessWidener": "wurst.accesswidener",
"depends": {
"fabricloader": ">=0.16.3",
"fabric-api": ">=0.103.1",
"minecraft": "~1.21.2-alpha.24.35.a",
"fabric-api": ">=0.103.2",
"minecraft": "~1.21.2-alpha.24.36.a",
"java": ">=21"
},
"suggests": {

View File

@ -3,7 +3,8 @@ accessible class net/minecraft/client/render/BackgroundRenderer$StatusEffectFogM
accessible method net/minecraft/client/MinecraftClient doItemUse ()V
accessible method net/minecraft/client/Mouse onMouseButton (JIII)V
accessible method net/minecraft/client/render/BackgroundRenderer getFogModifier (Lnet/minecraft/entity/Entity;F)Lnet/minecraft/client/render/BackgroundRenderer$StatusEffectFogModifier;
accessible method net/minecraft/client/render/GameRenderer method_62904 (Lnet/minecraft/util/Identifier;)V
accessible method net/minecraft/client/render/GameRenderer setPostProcessor (Lnet/minecraft/util/Identifier;)V
accessible method net/minecraft/entity/player/PlayerEntity canGlide ()Z
accessible method net/minecraft/entity/projectile/FishingBobberEntity isOpenOrWaterAround (Lnet/minecraft/util/math/BlockPos;)Z
accessible field net/minecraft/client/MinecraftClient itemUseCooldown I
accessible field net/minecraft/client/gui/hud/ChatHud visibleMessages Ljava/util/List;
@ -19,4 +20,5 @@ 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/LivingEntity jumping Z
accessible field net/minecraft/network/packet/s2c/play/ChunkDeltaUpdateS2CPacket sectionPos Lnet/minecraft/util/math/ChunkSectionPos;