Skip to content

Commit

Permalink
Added getRadius()
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Macagno committed Aug 26, 2015
1 parent 9f79af8 commit 4d5aa0f
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/main/java/cr0s/warpdrive/config/structures/Orb.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ public abstract class Orb extends DeployableStructure implements XmlRepresentabl
private ArrayList<OrbShell> shells;
private String name;

/**
* @return the radius
*/
public int getRadius() {
return super.height / 2;
}

/**
* @param radius the radius to set
*/
public void setRadius(int radius) {

super.height = radius * 2;
super.length = radius * 2;
super.width = radius * 2;
}

public String getName() {
return name;
}
Expand All @@ -30,8 +47,10 @@ public void setName(String name) {
this.name = name;
}

public Orb(int diameter) {
super(diameter, diameter, diameter);
public Orb(int radius) {
super(radius * 2, radius * 2, radius * 2);

setRadius(radius);

}

Expand All @@ -49,6 +68,7 @@ public void loadFromXmlElement(Element e) throws InvalidXmlException {

OrbShell shell = new OrbShell();
shell.loadFromXmlElement(tmp);
shell.finishContruction();
totalThickness += shell.thickness;
newShells.add(shell);

Expand All @@ -63,6 +83,8 @@ public void loadFromXmlElement(Element e) throws InvalidXmlException {
shellRelative[index++] = shell;
}

setRadius(totalThickness - 1);


}

Expand All @@ -78,7 +100,7 @@ public void saveToXmlElement(Element e, Document d) {

@Override
public boolean generate(World world, Random p_76484_2_, int x, int y, int z) {
EntitySphereGen entitySphereGen = new EntitySphereGen(world, x, y, z, getHeight() / 2, this, true);
EntitySphereGen entitySphereGen = new EntitySphereGen(world, x, y, z, getRadius(), this, true);
world.spawnEntityInWorld(entitySphereGen);
return false;
}
Expand Down

0 comments on commit 4d5aa0f

Please sign in to comment.