aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/bscv/tools/Inventory.java
blob: b47950f20a0cfdd30e21f5b3fc8ffd4bd7965a44 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package ftbsc.bscv.tools;

import java.util.Collection;
import java.util.List;

import ftbsc.bscv.ICommons;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;

public class Inventory implements ICommons {

   public static final int HOTBAR_SIZE = 9;

   public static List<Slot> hotbar(ClientPlayerEntity player) {
      return player.inventoryMenu.slots.subList(36, 45);
   }

   // TODO ????????????? wtf is this is there an easier way?
   public static double itemDamage(ItemStack item) {
      Collection<AttributeModifier> damage_attrs =
         item.getAttributeModifiers(EquipmentSlotType.MAINHAND)
            .get(Attributes.ATTACK_DAMAGE);
      if (damage_attrs.isEmpty()) return 0.;
      double damage = Math.abs(damage_attrs.iterator().next().getAmount());
      Collection<AttributeModifier> speed_attrs =
         item.getAttributeModifiers(EquipmentSlotType.MAINHAND)
            .get(Attributes.ATTACK_SPEED);
      if (speed_attrs.isEmpty()) return damage;
      double speed = Math.abs(speed_attrs.iterator().next().getAmount());
      return damage * speed;
   }
}