-
Notifications
You must be signed in to change notification settings - Fork 754
/
IToolStackView.java
72 lines (55 loc) · 2.32 KB
/
IToolStackView.java
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package slimeknights.tconstruct.library.tools.nbt;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import slimeknights.tconstruct.library.tools.SlotType;
import slimeknights.tconstruct.library.tools.helper.ToolDamageUtil;
import slimeknights.tconstruct.library.tools.stat.INumericToolStat;
/**
* Provides mostly read only access to {@link ToolStack}.
* Used since modifiers should not be modifying the tool materials or modifiers in their behaviors.
* If you receive an instance of this interface a parameter, do NOT use an instanceof check and cast it to a ToolStack. Don't make me use a private wrapper class.
*/
public interface IToolStackView extends IToolContext {
/* Stats */
/** On built tools, contains the full tool stats. During tool rebuild, contains the base stats before considering modifiers. */
StatsNBT getStats();
/**
* Gets the tool stats if parsed, or parses from NBT if not yet parsed
* @return stats
*/
MultiplierNBT getMultipliers();
/** Commonly used operation, getting a stat multiplier */
default float getMultiplier(INumericToolStat<?> stat) {
return getMultipliers().get(stat);
}
/* Damage state */
/** Gets the current damage of the tool */
int getDamage();
/** Gets the current durability remaining for this tool */
int getCurrentDurability();
/** Checks whether the tool is broken */
boolean isBroken();
/** If true, tool is marked unbreakable by vanilla */
boolean isUnbreakable();
/**
* Sets the tools current damage.
* Note in general you should use {@link ToolDamageUtil#damage(IToolStackView, int, LivingEntity, ItemStack)} or {@link ToolDamageUtil#repair(IToolStackView, int)} as they handle modifiers
* @param damage New damage
*/
void setDamage(int damage);
/**
* Gets persistent modifier data from the tool.
* This data may be edited by modifiers and will persist when stats rebuild
* TODO 1.19: change return type to NamespaceNBT as modifiers should not be changing slots, will make bow hooks easier
*/
@Override
ModDataNBT getPersistentData();
/* Helpers */
/**
* Gets the free upgrade slots remaining on the tool
* @return Free upgrade slots
*/
default int getFreeSlots(SlotType type) {
return getPersistentData().getSlots(type) + getVolatileData().getSlots(type);
}
}