aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java
blob: ea0552516608ccd561ee79596f7d1d5422884b57 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package gtPlusPlus.plugin.villagers.tile;

import java.util.HashMap;

import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntityMobSpawner;

public class TileEntityGenericSpawner extends TileEntityMobSpawner {
	
	/*
	 * Static Variables
	 */
	
	/**
	 * The Mob Spawner Map
	 */
	public static HashMap<Integer, Entity> mSpawners = new HashMap<Integer, Entity>();
	
	/**
	 * Registers a New Mob Spawner Type
	 * @param aID - the Spawner type ID
	 * @param aEntity - the Entity which you'd like to spawn
	 */
	public static boolean registerNewMobSpawner(int aID, Entity aEntity) {
		int registered = mSpawners.size();
		mSpawners.put(aID, aEntity);
		return mSpawners.size() > registered;
	}
	
	/*
	 * Instance Variables
	 */
	
	/**
	 * The {@link Entity} type which spawns.
	 */
	private final Entity mSpawnType;
	
	
	
	/*
	 * Constructors
	 */
	
	/**
	 * Constructs a new Spawner, based on an existing type registered.
	 * @param aID - The ID in the {@link mSpawners} map.
	 */
	public TileEntityGenericSpawner(int aID) {
		if (mSpawners.get(aID) != null) {
			mSpawnType = mSpawners.get(aID);			
		}
		else {
			mSpawnType = null;
		}
	}


	/**
	 * Constructs a new Spawner, then registers it.
	 * @param aID - The ID to be used in the {@link mSpawners} map.
	 * @param aEntity - The {@link Entity} type which will be spawned.
	 */
	public TileEntityGenericSpawner(int aID, Entity aEntity) {
		if (aEntity != null) {
			mSpawnType = aEntity;
			this.registerNewMobSpawner(aID, aEntity);
		}
		else {
			mSpawnType = null;
		}
	}
	

}