aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/bloodasp/galacticgreg/schematics/SpaceSchematic.java
blob: 606f2318adb95e2ce24cb1f78bcf729977b57d02 (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
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
package bloodasp.galacticgreg.schematics;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

import net.minecraft.block.Block;
import net.minecraft.util.Vec3;
import bloodasp.galacticgreg.api.StructureInformation;

/**
 * Class for XML Structure files. You only should edit/use this file/class if you want to add/fix stuff with 
 * GalacticGreg itself, and never if you're a mod developer and want to add support for GGreg to your mod.
 * However, feel free to copy this code to your own mod to implement structures. If you have questions, find me on github
 * and ask 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "SpaceSchematic")
public class SpaceSchematic {
	@XmlAttribute(name = "enabled")
	protected boolean _mStructureEnabled;
	@XmlAttribute(name="centerX")
	protected int _mCenterX;
	@XmlAttribute(name="centerY")
	protected int _mCenterY;
	@XmlAttribute(name="centerZ")
	protected int _mCenterZ;
	
	@XmlElement(name = "StructureName")
	protected String _mStructureName;

	@XmlElement(name = "Rarity")
	protected int _mRarity;
	
	@XmlElementWrapper(name = "Coords")
	@XmlElement(name="block")
	protected ArrayList<BaseStructureInfo> mStructureInfoList;

	public boolean isEnabled()
	{
		return _mStructureEnabled;
	}

	public Vec3 getStructureCenter()
	{
		return Vec3.createVectorHelper(_mCenterX, _mCenterY, _mCenterZ);
	}
	
	public int getRarity()
	{
		return _mRarity;
	}
	
	public String getName()
	{
		return _mStructureName;
	}
	
	public ArrayList<BaseStructureInfo> coordInfo()
	{
		if (mStructureInfoList == null)
			mStructureInfoList = new ArrayList<BaseStructureInfo>();
		
		return mStructureInfoList;
	}
	
	public void addStructureInfo(StructureInformation pStrucInfo)
	{
		if (mStructureInfoList == null)
			mStructureInfoList = new ArrayList<BaseStructureInfo>();
		mStructureInfoList.add(new BaseStructureInfo(pStrucInfo));
	}
	
	public static class BaseStructureInfo
	{
		@XmlAttribute(name = "X")
		protected int posX;
		@XmlAttribute(name = "Y")
		protected int posY;
		@XmlAttribute(name = "Z")
		protected int posZ;
		@XmlAttribute(name = "Block")
		protected String blockName;		
		@XmlAttribute(name = "Meta")
		protected int blockMeta;		
		
		public BaseStructureInfo(StructureInformation pSI)
		{
			posX = pSI.getX();
			posY = pSI.getY();
			posZ = pSI.getZ();
			blockName = Block.blockRegistry.getNameForObject(pSI.getBlock().getBlock());
			blockMeta = pSI.getBlock().getMeta();
		}
		
		public Vec3 getVec3Pos()
		{
			return Vec3.createVectorHelper(posX, posY, posZ);
		}
	}
}