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
|
package ihl.explosion;
import ic2.core.IC2;
import ihl.IHLMod;
import ihl.utils.IHLMathUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
public class ExplosiveTileEntity extends TileEntity {
public int explosionPower=10000;
private int explosionType=1;
private int detonator_delay=1;
private int burn_time=0;
public boolean is_detonator_burning = false;
public void createExplosion(EntityPlayer player)
{
this.invalidate();
int power = this.explosionPower;
this.explosionPower = 0;
IHLMod.explosionHandler.setPower(IHLMod.explosionHandler.startVectors, power);
IHLMod.explosionHandler.doExplosion(worldObj, xCoord, yCoord, zCoord, IHLMod.explosionHandler.startVectors);
IHLMod.proxy.createExplosionEffectFromServer(worldObj, xCoord, yCoord, zCoord, 32f*IHLMathUtils.sqrt(power/16384f));
}
@Override
public boolean canUpdate()
{
return IC2.platform.isSimulating();
}
@Override
public void updateEntity()
{
if(is_detonator_burning)
{
IHLMod.proxy.spawnParticleFromServer(4, worldObj, xCoord+0.5d, yCoord+1d, zCoord+0.5d, 0d, 0.2d, 0d, 1f);
if(this.burn_time++>detonator_delay*20)
{
this.createExplosion(null);
}
}
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
if(nbt!=null)
{
explosionPower=nbt.getInteger("explosionPower");
explosionType=nbt.getInteger("explosionType");
detonator_delay=nbt.getInteger("detonator_delay");
}
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
nbt.setInteger("explosionPower",explosionPower);
nbt.setInteger("explosionType",explosionType);
nbt.setInteger("detonator_delay",detonator_delay);
}
public boolean ignite(EntityPlayer player)
{
if(player!=null &&
player.getCurrentEquippedItem()!=null &&
player.getCurrentEquippedItem().getItem()==Items.flint_and_steel)
{
ignite();
return true;
}
return false;
}
public void ignite()
{
IHLMod.proxy.playSoundEffectFromServer(0, this.worldObj, this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 10.0F, 1.0F);
this.is_detonator_burning=true;
}
}
|