-
Notifications
You must be signed in to change notification settings - Fork 755
/
PlayerAbilityHelper.java
111 lines (98 loc) · 3.4 KB
/
PlayerAbilityHelper.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
package tconstruct.armor;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.*;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.*;
import net.minecraft.potion.*;
import tconstruct.armor.player.*;
public class PlayerAbilityHelper
{
public static void toggleGoggles (EntityPlayer player, boolean active)
{
TPlayerStats stats = TPlayerStats.get(player);
stats.activeGoggles = active;
if (!stats.activeGoggles)
{
player.removePotionEffect(Potion.nightVision.id);
}
else
{
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 15 * 20, 0, true));
}
}
public static void swapBelt (EntityPlayer player, ArmorExtended armor)
{
NBTTagList slots = new NBTTagList();
InventoryPlayer hotbar = player.inventory;
NBTTagCompound itemTag;
for (int i = 0; i < 9; ++i)
{
if (hotbar.mainInventory[i] != null)
{
itemTag = new NBTTagCompound();
itemTag.setByte("Slot", (byte) i);
hotbar.mainInventory[i].writeToNBT(itemTag);
slots.appendTag(itemTag);
}
hotbar.mainInventory[i] = null;
}
ItemStack belt = armor.inventory[3];
NBTTagList replaceSlots = belt.getTagCompound().getTagList("Inventory", 10);
for (int i = 0; i < replaceSlots.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = replaceSlots.getCompoundTagAt(i);
int j = nbttagcompound.getByte("Slot") & 255;
ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound);
if (itemstack != null)
{
if (j >= 0 && j < hotbar.mainInventory.length)
{
hotbar.mainInventory[j] = itemstack;
}
}
}
belt.getTagCompound().setTag("Inventory", slots);
}
public static void setEntitySize (Entity entity, float width, float height)
{
float f2;
if (width != entity.width || height != entity.height)
{
f2 = entity.width;
entity.width = width;
entity.height = height;
entity.boundingBox.maxX = entity.boundingBox.minX + (double) entity.width;
entity.boundingBox.maxZ = entity.boundingBox.minZ + (double) entity.width;
entity.boundingBox.maxY = entity.boundingBox.minY + (double) entity.height;
if (entity.width > f2 && !entity.worldObj.isRemote)
{
entity.moveEntity((double) (f2 - entity.width), 0.0D, (double) (f2 - entity.width));
}
}
f2 = width % 2.0F;
if ((double) f2 < 0.375D)
{
entity.myEntitySize = Entity.EnumEntitySize.SIZE_1;
}
else if ((double) f2 < 0.75D)
{
entity.myEntitySize = Entity.EnumEntitySize.SIZE_2;
}
else if ((double) f2 < 1.0D)
{
entity.myEntitySize = Entity.EnumEntitySize.SIZE_3;
}
else if ((double) f2 < 1.375D)
{
entity.myEntitySize = Entity.EnumEntitySize.SIZE_4;
}
else if ((double) f2 < 1.75D)
{
entity.myEntitySize = Entity.EnumEntitySize.SIZE_5;
}
else
{
entity.myEntitySize = Entity.EnumEntitySize.SIZE_6;
}
}
}