-
Notifications
You must be signed in to change notification settings - Fork 754
/
SlimeClone.java
175 lines (145 loc) · 4.53 KB
/
SlimeClone.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package tconstruct.entity;
import tconstruct.TConstruct;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
public class SlimeClone extends GolemBase implements IEntityAdditionalSpawnData
{
public float sizeOffset;
public float sizeFactor;
public float sizeHeight;
public String username = "";
public String skinUrl = "";
public SlimeClone(World world)
{
super(world);
//this.texture = "/mob/char.png";
}
public SlimeClone(World world, String username)
{
this(world);
this.username = username;
}
/*@Override
public void initCreature ()
{
maxHealth = 100;
//health = 100;
baseAttack = 3;
paused = false;
}*/
public void onUpdate ()
{
if (!this.worldObj.isRemote && this.worldObj.difficultySetting == 0 && this.getSlimeSize() > 0)
{
this.isDead = true;
}
this.sizeFactor += (this.sizeOffset - this.sizeFactor) * 0.5F;
this.sizeHeight = this.sizeFactor;
boolean flag = this.onGround;
super.onUpdate();
float i;
if (this.onGround && !flag)
{
i = this.getSlimeSize();
for (int j = 0; j < i * 8; ++j)
{
float f = this.rand.nextFloat() * (float) Math.PI * 2.0F;
float offset = this.rand.nextFloat() * 0.5F + 0.5F;
float xPos = MathHelper.sin(f) * (float) i * 0.5F * offset;
float zPos = MathHelper.cos(f) * (float) i * 0.5F * offset;
TConstruct.proxy.spawnParticle(this.getSlimeParticle(), this.posX + (double) xPos, this.boundingBox.minY, this.posZ + (double) zPos, 0.0D, 0.0D, 0.0D);
}
if (this.makesSoundOnLand())
{
this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) / 0.8F);
}
this.sizeOffset = -0.5F;
}
else if (!this.onGround && flag)
{
this.sizeOffset = 1.0F;
}
this.func_70808_l();
if (this.worldObj.isRemote)
{
i = this.getSlimeSize();
this.setSize(0.6F * (float) i, 0.6F * (float) i);
}
}
protected void func_70808_l ()
{
this.sizeOffset *= 0.6F;
}
protected String getJumpSound ()
{
return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small");
}
public void jump ()
{
this.motionY = 0.05 * getSlimeSize() + 0.37;
if (this.isPotionActive(Potion.jump))
{
this.motionY += (double) ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
}
if (this.isSprinting())
{
float f = this.rotationYaw * 0.017453292F;
this.motionX -= (double) (MathHelper.sin(f) * 0.2F);
this.motionZ += (double) (MathHelper.cos(f) * 0.2F);
}
this.isAirBorne = true;
ForgeHooks.onLivingJump(this);
}
protected void fall (float par1)
{
}
protected String getSlimeParticle ()
{
return "blueslime";
}
public float getSlimeSize ()
{
return 1.5f;
}
/**
* Returns true if the slime makes a sound when it jumps (based upon the slime's size)
*/
protected boolean makesSoundOnJump ()
{
return this.getSlimeSize() > 0;
}
/**
* Returns true if the slime makes a sound when it lands after a jump (based upon the slime's size)
*/
protected boolean makesSoundOnLand ()
{
return this.getSlimeSize() > 2;
}
public void writeEntityToNBT (NBTTagCompound tags)
{
super.writeEntityToNBT(tags);
tags.setString("Username", username);
}
public void readEntityFromNBT (NBTTagCompound tags)
{
super.readEntityFromNBT(tags);
username = tags.getString("Username");
}
@Override
public void writeSpawnData (ByteArrayDataOutput data)
{
data.writeUTF(username);
}
@Override
public void readSpawnData (ByteArrayDataInput data)
{
username = data.readUTF();
skinUrl = "http://skins.minecraft.net/MinecraftSkins/" + username + ".png";
}
}