Search in sources :

Example 6 with StructureGroup

use of am2.api.blocks.MultiblockStructureDefinition.StructureGroup in project ArsMagica2 by Mithion.

the class TileEntityCraftingAltar method checkStructure.

private void checkStructure() {
    if ((isCrafting && checkCounter++ < 50) || (!isCrafting && checkCounter++ < 200)) {
        return;
    }
    checkCounter = 0;
    boolean primaryvalid = primary.checkStructure(worldObj, xCoord, yCoord, zCoord);
    boolean secondaryvalid = secondary.checkStructure(worldObj, xCoord, yCoord, zCoord);
    if (!primaryvalid && !secondaryvalid) {
        if (isCrafting)
            setCrafting(false);
    }
    //locate lectern and lever & material groups
    if (primaryvalid || secondaryvalid) {
        maxEffects = 0;
        ArrayList<StructureGroup> lecternGroups = null;
        ArrayList<StructureGroup> augmatlGroups = null;
        ArrayList<StructureGroup> mainmatlGroups = null;
        if (primaryvalid) {
            lecternGroups = primary.getMatchedGroups(lectern_mutex, worldObj, xCoord, yCoord, zCoord);
            augmatlGroups = primary.getMatchedGroups(augmatl_mutex, worldObj, xCoord, yCoord, zCoord);
            mainmatlGroups = primary.getMatchedGroups(MultiblockStructureDefinition.MAINGROUP_MUTEX, worldObj, xCoord, yCoord, zCoord);
        } else if (secondaryvalid) {
            lecternGroups = secondary.getMatchedGroups(lectern_mutex, worldObj, xCoord, yCoord, zCoord);
            augmatlGroups = secondary.getMatchedGroups(augmatl_mutex, worldObj, xCoord, yCoord, zCoord);
            mainmatlGroups = secondary.getMatchedGroups(MultiblockStructureDefinition.MAINGROUP_MUTEX, worldObj, xCoord, yCoord, zCoord);
        }
        if (lecternGroups != null && lecternGroups.size() > 0) {
            StructureGroup group = lecternGroups.get(0);
            HashMap<BlockCoord, ArrayList<BlockDec>> blocks = group.getAllowedBlocks();
            for (BlockCoord bc : blocks.keySet()) {
                Block block = worldObj.getBlock(xCoord + bc.getX(), yCoord + bc.getY(), zCoord + bc.getZ());
                if (block == BlocksCommonProxy.blockLectern) {
                    podiumLocation = bc;
                } else if (block == Blocks.lever) {
                    switchLocation = bc;
                }
            }
        }
        if (augmatlGroups != null && augmatlGroups.size() == 1) {
            StructureGroup group = augmatlGroups.get(0);
            int index = -1;
            for (StructureGroup augmatlGroup : primaryvalid ? augMatl_primary : augMatl_secondary) {
                index++;
                if (augmatlGroup == group) {
                    break;
                }
            }
            maxEffects = index + 1;
        }
        if (mainmatlGroups != null && mainmatlGroups.size() == 1) {
            StructureGroup group = mainmatlGroups.get(0);
            if (group == wood_primary || group == wood_secondary)
                maxEffects += 1;
            else if (group == cobble_primary || group == cobble_secondary || group == sandstone_primary || group == sandstone_secondary)
                maxEffects += 1;
            else if (group == brick_primary || group == brick_secondary || group == witchwood_primary || group == witchwood_secondary)
                maxEffects += 2;
            else if (group == netherbrick_primary || group == netherbrick_secondary || group == quartz_primary || group == quartz_secondary)
                maxEffects += 3;
            else
                //default of stone brick
                maxEffects += 2;
        }
    } else {
        podiumLocation = null;
        switchLocation = null;
        maxEffects = 0;
    }
    //maxEffects = 2;
    setStructureValid(primaryvalid || secondaryvalid);
}
Also used : StructureGroup(am2.api.blocks.MultiblockStructureDefinition.StructureGroup) ArrayList(java.util.ArrayList) Block(net.minecraft.block.Block) BlockCoord(am2.api.blocks.MultiblockStructureDefinition.BlockCoord)

Example 7 with StructureGroup

use of am2.api.blocks.MultiblockStructureDefinition.StructureGroup in project ArsMagica2 by Mithion.

the class RitualShapeHelper method initHourglass.

private void initHourglass() {
    hourglass = new MultiblockStructureDefinition("hourglass");
    StructureGroup eastWest = hourglass.createGroup("WE", 2);
    StructureGroup northSouth = hourglass.createGroup("NS", 2);
    //center
    hourglass.addAllowedBlock(eastWest, 0, 0, 0, BlocksCommonProxy.wizardChalk);
    //offset
    hourglass.addAllowedBlock(eastWest, -1, 0, 1, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(eastWest, -1, 0, -1, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(eastWest, 1, 0, 1, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(eastWest, 1, 0, -1, BlocksCommonProxy.wizardChalk);
    //edges
    hourglass.addAllowedBlock(eastWest, -2, 0, 1, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(eastWest, -2, 0, 0, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(eastWest, -2, 0, -1, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(eastWest, 2, 0, 1, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(eastWest, 2, 0, 0, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(eastWest, 2, 0, -1, BlocksCommonProxy.wizardChalk);
    //center
    hourglass.addAllowedBlock(northSouth, 0, 0, 0, BlocksCommonProxy.wizardChalk);
    //offset
    hourglass.addAllowedBlock(northSouth, 1, 0, -1, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(northSouth, -1, 0, -1, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(northSouth, 1, 0, 1, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(northSouth, -1, 0, 1, BlocksCommonProxy.wizardChalk);
    //edges
    hourglass.addAllowedBlock(northSouth, 1, 0, -2, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(northSouth, 0, 0, -2, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(northSouth, -1, 0, -2, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(northSouth, 1, 0, 2, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(northSouth, 0, 0, 2, BlocksCommonProxy.wizardChalk);
    hourglass.addAllowedBlock(northSouth, -1, 0, 2, BlocksCommonProxy.wizardChalk);
}
Also used : StructureGroup(am2.api.blocks.MultiblockStructureDefinition.StructureGroup) MultiblockStructureDefinition(am2.api.blocks.MultiblockStructureDefinition)

Example 8 with StructureGroup

use of am2.api.blocks.MultiblockStructureDefinition.StructureGroup in project ArsMagica2 by Mithion.

the class GuiArcaneCompendium method getMultiblockLayer.

private TreeMap<BlockCoord, ArrayList<BlockDec>> getMultiblockLayer(int layer) {
    TreeMap<BlockCoord, ArrayList<BlockDec>> layerBlocksSorted = new TreeMap<BlockCoord, ArrayList<BlockDec>>();
    for (int mutex : entryMultiblock.getMutexList()) {
        ArrayList<StructureGroup> groups = entryMultiblock.getGroupsForMutex(mutex);
        StructureGroup selected = groups.get(AMGuiHelper.instance.getSlowTicker() % groups.size());
        HashMap<BlockCoord, ArrayList<BlockDec>> layerBlocks = entryMultiblock.getStructureLayer(selected, layer);
        for (BlockCoord bc : layerBlocks.keySet()) {
            layerBlocksSorted.put(bc, layerBlocks.get(bc));
        }
    }
    return layerBlocksSorted;
}
Also used : StructureGroup(am2.api.blocks.MultiblockStructureDefinition.StructureGroup) BlockDec(am2.api.blocks.MultiblockStructureDefinition.BlockDec) BlockCoord(am2.api.blocks.MultiblockStructureDefinition.BlockCoord)

Aggregations

StructureGroup (am2.api.blocks.MultiblockStructureDefinition.StructureGroup)7 MultiblockStructureDefinition (am2.api.blocks.MultiblockStructureDefinition)3 BlockCoord (am2.api.blocks.MultiblockStructureDefinition.BlockCoord)2 Block (net.minecraft.block.Block)2 BlockDec (am2.api.blocks.MultiblockStructureDefinition.BlockDec)1 ArrayList (java.util.ArrayList)1