summaryrefslogtreecommitdiff
path: root/YWD/src/main/java/fyresmodjam/tileentities/TileEntityCrystal.java
blob: 3960f4527310edf8734239a99ac261b80574e2e0 (plain)
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
package fyresmodjam.tileentities;

import java.util.Random;

import fyresmodjam.items.ItemCrystal;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;

public class TileEntityCrystal extends TileEntity {
	public TileEntityCrystal() {
	}

	public static Random random = new Random();

	@Override
	public void updateEntity() {
		super.updateEntity();

		if (random.nextInt(4) == 0) {
			worldObj.spawnParticle(
					ItemCrystal.particleNames[getBlockMetadata()
							% ItemCrystal.particleNames.length],
					xCoord + random.nextFloat(),
					yCoord + random.nextFloat(),
					zCoord + random.nextFloat(), 0.0f,
					0.0f, 0.0f);
		}
	}

	@Override
	public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
		super.writeToNBT(par1NBTTagCompound);
	}

	@Override
	public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
		super.readFromNBT(par1NBTTagCompound);
	}

	@Override
	public Packet getDescriptionPacket() {
		NBTTagCompound tag = new NBTTagCompound();
		writeToNBT(tag);
		return new S35PacketUpdateTileEntity(xCoord, yCoord,
				zCoord, 1, tag);
	}

	@Override
	public void onDataPacket(NetworkManager net,
			S35PacketUpdateTileEntity pkt) {
		readFromNBT(pkt.func_148857_g());
	}
}