/
BabyHeatscarSpider.java
190 lines (164 loc) · 5.07 KB
/
BabyHeatscarSpider.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
package mods.natura.entity;
import mods.natura.common.NContent;
import net.minecraft.block.Block;
import net.minecraft.block.Block.SoundType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
public class BabyHeatscarSpider extends EntitySpider
{
public BabyHeatscarSpider(World par1World)
{
super(par1World);
this.setSize(1.2F, 0.8F);
this.isImmuneToFire = true;
}
public float spiderScaleAmount ()
{
return 0.85F;
}
@Override
protected void attackEntity (Entity par1Entity, float par2)
{
if (par2 > 2.0F && par2 < 6.0F && this.rand.nextInt(10) == 0)
{
if (this.onGround)
{
double d0 = par1Entity.posX - this.posX;
double d1 = par1Entity.posZ - this.posZ;
float f2 = MathHelper.sqrt_double(d0 * d0 + d1 * d1);
this.motionX = d0 / f2 * 0.5D + this.motionX * 0.20000000298023224D;
this.motionZ = d1 / f2 * 0.5D + this.motionZ * 0.20000000298023224D;
this.motionY = 0.62D;
}
}
else
{
super.attackEntity(par1Entity, par2);
}
}
@Override
public void jump ()
{
this.motionY = 0.62D;
if (this.isPotionActive(Potion.jump))
{
this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F;
}
if (this.isSprinting())
{
float f = this.rotationYaw * 0.017453292F;
this.motionX -= MathHelper.sin(f) * 0.2F;
this.motionZ += MathHelper.cos(f) * 0.2F;
}
this.isAirBorne = true;
ForgeHooks.onLivingJump(this);
}
@Override
protected void fall (float par1)
{
par1 = ForgeHooks.onLivingFall(this, par1);
if (par1 <= 0)
{
return;
}
super.fall(par1);
int i = MathHelper.ceiling_float_int(par1 - 5.0F);
if (i > 0)
{
if (i > 4)
{
this.playSound("damage.fallbig", 1.0F, 1.0F);
}
else
{
this.playSound("damage.fallsmall", 1.0F, 1.0F);
}
this.attackEntityFrom(DamageSource.fall, i);
Block j = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY - 0.20000000298023224D - this.yOffset), MathHelper.floor_double(this.posZ));
if (j != null)
{
SoundType stepsound = j.stepSound;
this.playSound(stepsound.soundName, stepsound.getVolume() * 0.5F, stepsound.getPitch() * 0.75F);
}
}
}
@Override
public boolean attackEntityAsMob (Entity par1Entity)
{
if (super.attackEntityAsMob(par1Entity))
{
if (par1Entity instanceof EntityLiving)
{
byte b0 = 0;
if (this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL)
{
if (this.worldObj.difficultySetting == EnumDifficulty.NORMAL)
{
b0 = 5;
}
else if (this.worldObj.difficultySetting == EnumDifficulty.HARD)
{
b0 = 10;
}
}
if (b0 > 0)
{
par1Entity.setFire(b0);
}
}
return true;
}
else
{
return false;
}
}
public int getAttackStrength (Entity par1Entity)
{
return 4;
}
@Override
protected Item getDropItem()
{
return NContent.plantItem;
}
@Override
// dropItemWithOffset
public EntityItem func_145778_a(Item item, int par2, float offset)
{
return this.entityDropItem(new ItemStack(item, par2, 7), offset);
}
@Override
protected void dropFewItems (boolean par1, int par2)
{
Item j = this.getDropItem();
if (Item.getIdFromItem(j) > 0)
{
int k = this.rand.nextInt(3) + 2;
if (par2 > 0)
{
k += this.rand.nextInt(par2 + 1);
}
for (int l = 0; l < k; ++l)
{
this.dropItem(j, 1);
}
}
}
@Override
public boolean getCanSpawnHere ()
{
return this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL && this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty()
&& !this.worldObj.isAnyLiquid(this.boundingBox);
}
}