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
|
package jp.plusplus.fbs.entity;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import jp.plusplus.fbs.event.FBSEventHandler;
import jp.plusplus.fbs.particle.EntityTracksFX;
import jp.plusplus.fbs.particle.EntityTrajectoryFX;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.*;
import net.minecraft.world.World;
import java.util.LinkedList;
/**
* Createdby pluslus_Fon 2015/06/14.
*/
public class EntityMagicHealingBall extends EntityMagicProjectileBase {
LinkedList<Integer> entityIds=new LinkedList<Integer>();
int amplifier;
public EntityMagicHealingBall(World p_i1582_1_) {
super(p_i1582_1_);
this.setSize(0.25F, 0.25F);
}
public EntityMagicHealingBall(World par1World, EntityLivingBase par2EntityLivingBase, int amp) {
super(par1World, par2EntityLivingBase, 0, 0, 0, 0, 0);
amplifier=amp;
setPosition(posX, posY - 0.2D, posZ);
this.setSize(0.8F, 0.8F);
}
@Override
protected void readEntityFromNBT(NBTTagCompound nbt) {
super.readEntityFromNBT(nbt);
amplifier=nbt.getInteger("Amplifier");
entityIds=new LinkedList<Integer>();
int s=nbt.getInteger("ListSize");
for(int i=0;i<s;i++){
entityIds.add(nbt.getInteger("EntityIds-Id"+i));
}
}
@Override
protected void writeEntityToNBT(NBTTagCompound nbt) {
super.writeEntityToNBT(nbt);
nbt.setInteger("Amplifier", amplifier);
nbt.setInteger("ListSize", entityIds.size());
for(int i=0;i<entityIds.size();i++){
nbt.setInteger("EntityIds-Id"+i, entityIds.get(i));
}
}
@Override
public void onUpdate() {
super.onUpdate();
float s=MathHelper.sin(2 * 3.14159265f / 10.0f * (ticksExisted % 10));
float c=MathHelper.cos(2 * 3.14159265f / 10.0f * (ticksExisted % 10));
float mx=0.15f*c;
float my=0;
float mz=0.15f*s;
this.motionX = mx;
this.motionY = my;
this.motionZ = mz;
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(mx * mx + mz * mz);
this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(mx, mz) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(my, (double) f) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch;
this.prevRotationYaw = this.rotationYaw;
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
this.ticksInGround = 0;
}
}
@Override
public boolean canExist() {
return worldObj.isRemote || ticksExisted < 20 * 20;
}
@Override
public void onCollideWithPlayer(MovingObjectPosition pos, EntityPlayer entity) {
if (!worldObj.isRemote) {
for(Integer id : entityIds){
if(id==entity.getEntityId()){
return;
}
}
//entity.addPotionEffect(new PotionEffect(Potion.heal.getId(), 20, amplifier));
entity.setHealth(entity.getHealth()+0.5f*amplifier);
entityIds.add(entity.getEntityId());
}
}
@Override
public void onCollideWithLiving(MovingObjectPosition pos, EntityLiving entity) {
if (!worldObj.isRemote) {
for(Integer id : entityIds){
if(id==entity.getEntityId()){
return;
}
}
//entity.addPotionEffect(new PotionEffect(Potion.heal.getId(), 20, amplifier));
entity.setHealth(entity.getHealth() + 0.5f * amplifier);
entityIds.add(entity.getEntityId());
}
}
@Override
@SideOnly(Side.CLIENT)
protected void spawnParticle(){
//setParticleColor();
particleRed=particleBlue=0.5f+0.2f*rand.nextFloat();
particleGreen=1.f;
EntityTracksFX fx=new EntityTracksFX(worldObj, posX, posY, posZ, 0, -(0.3f+0.6f*rand.nextFloat()), 0, particleRed, particleGreen, particleBlue, getParticleSize());
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
}
}
|