mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-22 13:09:42 +00:00
Added a structure cost preview.
This commit is contained in:
1 parent
e9f99e972d
commit
80235194b6
4 files changed
+63
-7
No files matched your search
@@ -13,12 +13,10 @@ package vazkii.botania.api.lexicon.multiblock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Mult;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
|
||||
|
||||
/**
|
||||
* This class describes a Mutiblock object. It's used to display a
|
||||
@@ -28,6 +26,7 @@ import net.minecraft.util.ChunkCoordinates;
|
||||
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;
|
||||
|
||||
@@ -38,6 +37,7 @@ public class Multiblock {
|
||||
public void addComponent(MultiblockComponent component) {
|
||||
components.add(component);
|
||||
changeAxisForNewComponent(component.relPos.posX, component.relPos.posY, component.relPos.posZ);
|
||||
calculateCostForNewComponent(component);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,6 +65,26 @@ public class Multiblock {
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user