-
Notifications
You must be signed in to change notification settings - Fork 755
/
TPlayerStats.java
121 lines (99 loc) · 3.56 KB
/
TPlayerStats.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package tconstruct.armor.player;
import java.lang.ref.WeakReference;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;
import tconstruct.api.IPlayerExtendedInventoryWrapper;
public class TPlayerStats implements IExtendedEntityProperties, IPlayerExtendedInventoryWrapper //TODO: IExtendedEntityProperties is not appropriate!
{
public static final String PROP_NAME = "TConstruct";
public WeakReference<EntityPlayer> player;
public int level;
public int bonusHealth;
public int damage;
public int hunger;
public int previousDimension;
public int mineSpeed;
public boolean climbWalls;
public boolean activeGoggles = true;
public boolean beginnerManual;
public boolean materialManual;
public boolean smelteryManual;
public boolean battlesignBonus;
public ArmorExtended armor;
public KnapsackInventory knapsack;
public TPlayerStats()
{
}
public TPlayerStats(EntityPlayer entityplayer)
{
this.player = new WeakReference<EntityPlayer>(entityplayer);
this.armor = new ArmorExtended();
this.armor.init(entityplayer);
this.knapsack = new KnapsackInventory();
this.knapsack.init(entityplayer);
}
@Override
public void saveNBTData (NBTTagCompound compound)
{
NBTTagCompound tTag = new NBTTagCompound();
armor.saveToNBT(tTag);
knapsack.saveToNBT(tTag);
tTag.setBoolean("beginnerManual", this.beginnerManual);
tTag.setBoolean("materialManual", this.materialManual);
tTag.setBoolean("smelteryManual", this.smelteryManual);
tTag.setBoolean("battlesignBonus", this.battlesignBonus);
compound.setTag(PROP_NAME, tTag);
}
@Override
public void loadNBTData (NBTTagCompound compound)
{
NBTTagCompound properties = (NBTTagCompound) compound.getTag(PROP_NAME);
this.armor.readFromNBT(properties);
this.knapsack.readFromNBT(properties);
this.beginnerManual = properties.getBoolean("beginnerManual");
this.materialManual = properties.getBoolean("materialManual");
this.smelteryManual = properties.getBoolean("smelteryManual");
this.battlesignBonus = properties.getBoolean("battlesignBonus");
}
@Override
public void init (Entity entity, World world)
{
}
public void copyFrom (TPlayerStats stats, boolean copyCalc)
{
this.armor = stats.armor;
this.knapsack = stats.knapsack;
this.beginnerManual = stats.beginnerManual;
this.materialManual = stats.materialManual;
this.smelteryManual = stats.smelteryManual;
this.battlesignBonus = stats.battlesignBonus;
if (copyCalc)
{
this.bonusHealth = stats.bonusHealth;
this.hunger = stats.hunger;
this.level = stats.level;
}
}
public static final void register (EntityPlayer player)
{
player.registerExtendedProperties(TPlayerStats.PROP_NAME, new TPlayerStats(player));
}
public static final TPlayerStats get (EntityPlayer player)
{
return (TPlayerStats) player.getExtendedProperties(PROP_NAME);
}
@Override
public IInventory getKnapsackInventory (EntityPlayer player)
{
return this.knapsack;
}
@Override
public IInventory getAccessoryInventory (EntityPlayer player)
{
return this.armor;
}
}