Some cleanup...

This commit is contained in:
Lizbeth Rika committed 2015-06-29 20:13:45 +01:00
1 parent 64109d9fcc
commit 49ed5a9d50
77 files changed
+341 -394

No files matched your search

@@ -24,15 +24,15 @@ import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
* look in the world.
*/
public class Multiblock {
public List<MultiblockComponent> components = new ArrayList();
public List<ItemStack> materials = new ArrayList();
public int minX, minY, minZ, maxX, maxY, maxZ, offX, offY, offZ;
/**
* Adds a multiblock component to this multiblock. The component's x y z
* coords should be pivoted to the center of the structure.
* coords should be pivoted to the center of the structure.
*/
public void addComponent(MultiblockComponent component) {
components.add(component);
@@ -47,54 +47,54 @@ public class Multiblock {
public void addComponent(int x, int y, int z, Block block, int meta) {
addComponent(new MultiblockComponent(new ChunkCoordinates(x, y, z), block, meta));
}
private void changeAxisForNewComponent(int x, int y, int z) {
if(x < minX)
minX = x;
else if(x > maxX)
maxX = x;
if(y < minY)
minY = y;
else if(y > maxY)
maxY = y;
if(z < minZ)
minZ = z;
else if(z > maxZ)
maxZ = z;
}
private void calculateCostForNewComponent(MultiblockComponent comp) {
ItemStack[] materials = comp.getMaterials();
if(materials != null)
for(ItemStack stack : materials)
addStack(stack);
}
private void addStack(ItemStack stack) {
if(stack == null)
return;
for(ItemStack oStack : materials)
if(oStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(oStack, stack)) {
oStack.stackSize += stack.stackSize;
return;
}
materials.add(stack);
}
public void setRenderOffset(int x, int y, int z) {
offX = x;
offY = y;
offZ = z;
}
public List<MultiblockComponent> getComponents() {
return components;
}
/**
* Rotates this multiblock by the angle passed in. For the best results, use
* only multiples of pi/2.
@@ -103,19 +103,19 @@ public class Multiblock {
for(MultiblockComponent comp : getComponents())
comp.rotate(angle);
}
public Multiblock copy() {
Multiblock mb = new Multiblock();
for(MultiblockComponent comp : getComponents())
mb.addComponent(comp.copy());
return mb;
}
/**
* Creates a length 4 array of all the rotations multiple of pi/2 required
* to render this multiblock in the world relevant to the 4 cardinal
* orientations.
* orientations.
*/
public Multiblock[] createRotations() {
Multiblock[] blocks = new Multiblock[4];
@@ -126,10 +126,10 @@ public class Multiblock {
blocks[2].rotate(Math.PI / 2);
blocks[3] = blocks[2].copy();
blocks[3].rotate(Math.PI / 2);
return blocks;
}
/**
* Makes a MultiblockSet from this Multiblock and its rotations using
* createRotations().
@@ -137,7 +137,7 @@ public class Multiblock {
public MultiblockSet makeSet() {
return new MultiblockSet(this);
}
public int getXSize() {
return Math.abs(minX) + Math.abs(maxX) + 1;
}
@@ -145,9 +145,9 @@ public class Multiblock {
public int getYSize() {
return Math.abs(minY) + Math.abs(maxY) + 1;
}
public int getZSize() {
return Math.abs(minZ) + Math.abs(maxZ) + 1;
}
}