mirror of
https://github.com/Wurst-Imperium/Wurst7.git
synced 2024-09-20 01:12:13 +02:00
Fix AutoSword not working with tridents
This commit is contained in:
parent
c5dce7f47a
commit
be0c08b077
@ -13,6 +13,7 @@ import net.minecraft.item.Item;
|
||||
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;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.wurstclient.Category;
|
||||
@ -33,12 +34,13 @@ public final class AutoSwordHack extends Hack implements UpdateListener
|
||||
new EnumSetting<>("Priority", Priority.values(), Priority.SPEED);
|
||||
|
||||
private final CheckboxSetting switchBack = new CheckboxSetting(
|
||||
"Switch back",
|
||||
"Switches back to the previously selected slot after \u00a7lRelease time\u00a7r has passed.",
|
||||
"Switch back", "Switches back to the previously selected slot after"
|
||||
+ " \u00a7lRelease time\u00a7r has passed.",
|
||||
true);
|
||||
|
||||
private final SliderSetting releaseTime = new SliderSetting("Release time",
|
||||
"Time until AutoSword will switch back from the weapon to the previously selected slot.\n\n"
|
||||
"Time until AutoSword will switch back from the weapon to the"
|
||||
+ " previously selected slot.\n\n"
|
||||
+ "Only works when \u00a7lSwitch back\u00a7r is checked.",
|
||||
10, 1, 200, 1,
|
||||
ValueDisplay.INTEGER.withSuffix(" ticks").withLabel(1, "1 tick"));
|
||||
@ -114,7 +116,7 @@ public final class AutoSwordHack extends Hack implements UpdateListener
|
||||
|
||||
Item item = MC.player.getInventory().getStack(i).getItem();
|
||||
|
||||
// get damage
|
||||
// get weapon value
|
||||
float value = getValue(item);
|
||||
|
||||
// compare with previous best weapon
|
||||
@ -145,15 +147,17 @@ public final class AutoSwordHack extends Hack implements UpdateListener
|
||||
switch(priority.getSelected())
|
||||
{
|
||||
case SPEED:
|
||||
if(item instanceof ToolItem tool)
|
||||
return ItemUtils.getAttackSpeed(tool);
|
||||
if(item instanceof ToolItem || item instanceof TridentItem)
|
||||
return ItemUtils.getAttackSpeed(item);
|
||||
break;
|
||||
|
||||
case DAMAGE:
|
||||
if(item instanceof SwordItem sword)
|
||||
return sword.getAttackDamage();
|
||||
if(item instanceof MiningToolItem miningTool)
|
||||
return miningTool.getAttackDamage();
|
||||
if(item instanceof MiningToolItem tool)
|
||||
return tool.getAttackDamage();
|
||||
if(item instanceof TridentItem)
|
||||
return TridentItem.ATTACK_DAMAGE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.attribute.EntityAttributes;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ToolItem;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
@ -56,7 +55,7 @@ public enum ItemUtils
|
||||
}
|
||||
}
|
||||
|
||||
public static float getAttackSpeed(ToolItem item)
|
||||
public static float getAttackSpeed(Item item)
|
||||
{
|
||||
return (float)item.getAttributeModifiers(EquipmentSlot.MAINHAND)
|
||||
.get(EntityAttributes.GENERIC_ATTACK_SPEED).stream().findFirst()
|
||||
|
Loading…
Reference in New Issue
Block a user