Search in sources :

Example 1 with IPrefixBlock

use of gregapi.block.IPrefixBlock in project gregtech6 by GregTech6.

the class Behavior_Plug_Leak method onItemUse.

@Override
public boolean onItemUse(MultiItem aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, byte aSide, float aHitX, float aHitY, float aHitZ) {
    if (aWorld.isRemote || aPlayer == null || !aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack))
        return F;
    for (byte tSide : ALL_SIDES) {
        // Only place right next to Liquids or inside of Liquids.
        if (!WD.liquid(WD.block(aWorld, aX + OFFX[aSide] + OFFX[tSide], aY + OFFY[aSide] + OFFY[tSide], aZ + OFFZ[aSide] + OFFZ[tSide])))
            continue;
        // Scan Inventory for suitable Items.
        for (int i = 0; i < aPlayer.inventory.mainInventory.length; i++) {
            ItemStack tStack = aPlayer.inventory.mainInventory[aPlayer.inventory.mainInventory.length - i - 1];
            if (ST.invalid(tStack))
                continue;
            Block tBlock = ST.block(tStack);
            // The Block has to be Opaque to ensure the Leak is plugged.
            if (tBlock == NB || !tBlock.isOpaqueCube())
                continue;
            // No Bedrock, Obsidian or Black Granite!
            if (WD.bedrock(tBlock) || tBlock.getHarvestLevel(ST.meta(tStack) & 15) >= 3)
                continue;
            // Don't use any PrefixBlocks, TileEntities or Silverfish Blocks.
            if (tBlock instanceof IPrefixBlock || tBlock instanceof ITileEntityProvider || tBlock instanceof BlockSilverfish)
                continue;
            // Only use Blocks that are typically mined.
            if (tBlock.getMaterial() != Material.rock && tBlock.getMaterial() != Material.ground && tBlock.getMaterial() != Material.sand && tBlock.getMaterial() != Material.clay)
                continue;
            // Don't use frikkin Ore Blocks or Storage Blocks for this!
            if (OM.prefixcontainsany(OM.anydata(tStack), TD.Prefix.ORE, TD.Prefix.STORAGE_BASED))
                continue;
            // No Thaumcraft Blocks!
            if (MD.TC.owns(tBlock))
                continue;
            int tOldSize = tStack.stackSize;
            if (tStack.tryPlaceItemIntoWorld(aPlayer, aWorld, aX, aY, aZ, aSide, aHitX, aHitY, aHitZ)) {
                if (UT.Entities.hasInfiniteItems(aPlayer)) {
                    tStack.stackSize = tOldSize;
                } else {
                    ST.use(aPlayer, T, tStack, 0);
                }
                return T;
            }
            return F;
        }
        return F;
    }
    return F;
}
Also used : ITileEntityProvider(net.minecraft.block.ITileEntityProvider) IPrefixBlock(gregapi.block.IPrefixBlock) Block(net.minecraft.block.Block) IPrefixBlock(gregapi.block.IPrefixBlock) BlockSilverfish(net.minecraft.block.BlockSilverfish) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IPrefixBlock

use of gregapi.block.IPrefixBlock in project gregtech6 by GregTech6.

the class DungeonChunkRoomStorage method generate.

@Override
public boolean generate(DungeonData aData) {
    if (!super.generate(aData))
        return F;
    Block tInfusedCrystal = ST.block(MD.TC, "blockCrystal"), tHexoriumColor = ST.block(MD.HEX, UT.Code.select(aData.mColor, "blockEnergizedHexoriumMonolithRainbow", HEXORIUM_MONOLITHS)), tHexoriumRandom = ST.block(MD.HEX, UT.Code.select("blockEnergizedHexoriumMonolithRainbow", HEXORIUM_MONOLITHS));
    FluidStack[][] tFluids = { { FL.Oil_Creosote.make(16000), FL.Oil_Seed.make(16000), FL.lube(16000), FL.Glue.make(16000), FL.Latex.make(16000), FL.Holywater.make(16000), FL.Purple_Drink.make(16000) }, { FL.Oil_Creosote.make(32000), FL.Oil_Seed.make(32000), FL.lube(32000), FL.Glue.make(32000), FL.Latex.make(32000), FL.Holywater.make(32000), FL.Purple_Drink.make(32000) }, { FL.Oil_Normal.make(64000), FL.Oil_Normal.make(64000), FL.Oil_Soulsand.make(64000), FL.Oil_Light.make(64000), FL.Oil_Medium.make(64000), FL.Oil_Heavy.make(64000), FL.Oil_ExtraHeavy.make(64000) } };
    short[] tIDs = new short[] { 32714, 32734, 32716 };
    if (aData.mRoomLayout[aData.mRoomX + 1][aData.mRoomZ] == 0) {
        if (aData.next1in2()) {
            int tType = aData.next(tIDs.length);
            for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) {
                if (aData.next1in2())
                    for (int k = 0; k < 4; k++) {
                        aData.set(12 + i, 1 + k, 6 + j, SIDE_UNKNOWN, tIDs[tType], new FluidTankGT(UT.Code.select(NF, tFluids[tType])).writeToNBT(UT.NBT.make(), NBT_TANK), T, T);
                        if (aData.next2in3())
                            break;
                    }
                else if (aData.next1in2()) {
                    switch(aData.next(3)) {
                        case 0:
                            aData.set(12 + i, 1, 6 + j, SIDE_UNKNOWN, 32055, new FluidTankGT(FL.Propane.make(8000)).writeToNBT(UT.NBT.make(NBT_COLOR, DYE_INT_Red, NBT_PAINTED, T), NBT_TANK), T, T);
                            break;
                        case 1:
                            aData.set(12 + i, 1, 6 + j, SIDE_UNKNOWN, 32056, new FluidTankGT(FL.Oxygen.make(8000)).writeToNBT(UT.NBT.make(NBT_COLOR, DYE_INT_LightBlue, NBT_PAINTED, T), NBT_TANK), T, T);
                            break;
                        case 2:
                            aData.set(12 + i, 1, 6 + j, SIDE_UNKNOWN, 32056, new FluidTankGT(FL.Helium.make(8000)).writeToNBT(UT.NBT.make(NBT_COLOR, DYE_INT_Yellow, NBT_PAINTED, T), NBT_TANK), T, T);
                            break;
                    }
                }
            }
        }
    }
    if (aData.mRoomLayout[aData.mRoomX - 1][aData.mRoomZ] == 0) {
        if (aData.next1in2()) {
            int tType = aData.next(tIDs.length);
            for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) {
                if (aData.next1in2())
                    for (int k = 0; k < 4; k++) {
                        aData.set(1 + i, 1 + k, 6 + j, SIDE_UNKNOWN, tIDs[tType], new FluidTankGT(UT.Code.select(NF, tFluids[tType])).writeToNBT(UT.NBT.make(), NBT_TANK), T, T);
                        if (aData.next2in3())
                            break;
                    }
                else if (aData.next1in2()) {
                    switch(aData.next(3)) {
                        case 0:
                            aData.set(1 + i, 1, 6 + j, SIDE_UNKNOWN, 32055, new FluidTankGT(FL.Propane.make(8000)).writeToNBT(UT.NBT.make(NBT_COLOR, DYE_INT_Red, NBT_PAINTED, T), NBT_TANK), T, T);
                            break;
                        case 1:
                            aData.set(1 + i, 1, 6 + j, SIDE_UNKNOWN, 32056, new FluidTankGT(FL.Oxygen.make(8000)).writeToNBT(UT.NBT.make(NBT_COLOR, DYE_INT_LightBlue, NBT_PAINTED, T), NBT_TANK), T, T);
                            break;
                        case 2:
                            aData.set(1 + i, 1, 6 + j, SIDE_UNKNOWN, 32056, new FluidTankGT(FL.Helium.make(8000)).writeToNBT(UT.NBT.make(NBT_COLOR, DYE_INT_Yellow, NBT_PAINTED, T), NBT_TANK), T, T);
                            break;
                    }
                }
            }
        }
    }
    if (aData.mRoomLayout[aData.mRoomX][aData.mRoomZ + 1] == 0) {
        if (aData.next1in2()) {
            int tType = aData.next(tIDs.length);
            for (int i = 0; i < 4; i++) for (int j = 0; j < 3; j++) {
                if (aData.next1in2())
                    for (int k = 0; k < 4; k++) {
                        aData.set(6 + i, 1 + k, 12 + j, SIDE_UNKNOWN, tIDs[tType], new FluidTankGT(UT.Code.select(NF, tFluids[tType])).writeToNBT(UT.NBT.make(), NBT_TANK), T, T);
                        if (aData.next2in3())
                            break;
                    }
                else if (aData.next1in2()) {
                    switch(aData.next(3)) {
                        case 0:
                            aData.set(6 + i, 1, 12 + j, SIDE_UNKNOWN, 32055, new FluidTankGT(FL.Propane.make(8000)).writeToNBT(UT.NBT.make(NBT_COLOR, DYE_INT_Red, NBT_PAINTED, T), NBT_TANK), T, T);
                            break;
                        case 1:
                            aData.set(6 + i, 1, 12 + j, SIDE_UNKNOWN, 32056, new FluidTankGT(FL.Oxygen.make(8000)).writeToNBT(UT.NBT.make(NBT_COLOR, DYE_INT_LightBlue, NBT_PAINTED, T), NBT_TANK), T, T);
                            break;
                        case 2:
                            aData.set(6 + i, 1, 12 + j, SIDE_UNKNOWN, 32056, new FluidTankGT(FL.Helium.make(8000)).writeToNBT(UT.NBT.make(NBT_COLOR, DYE_INT_Yellow, NBT_PAINTED, T), NBT_TANK), T, T);
                            break;
                    }
                }
            }
        }
    }
    if (aData.mRoomLayout[aData.mRoomX][aData.mRoomZ - 1] == 0) {
        if (aData.next1in2()) {
            int tType = aData.next(tIDs.length);
            for (int i = 0; i < 4; i++) for (int j = 0; j < 3; j++) {
                if (aData.next1in2())
                    for (int k = 0; k < 4; k++) {
                        aData.set(6 + i, 1 + k, 1 + j, SIDE_UNKNOWN, tIDs[tType], new FluidTankGT(UT.Code.select(NF, tFluids[tType])).writeToNBT(UT.NBT.make(), NBT_TANK), T, T);
                        if (aData.next2in3())
                            break;
                    }
                else if (aData.next1in2()) {
                    switch(aData.next(3)) {
                        case 0:
                            aData.set(6 + i, 1, 1 + j, SIDE_UNKNOWN, 32055, new FluidTankGT(FL.Propane.make(8000)).writeToNBT(UT.NBT.make(NBT_COLOR, DYE_INT_Red, NBT_PAINTED, T), NBT_TANK), T, T);
                            break;
                        case 1:
                            aData.set(6 + i, 1, 1 + j, SIDE_UNKNOWN, 32056, new FluidTankGT(FL.Oxygen.make(8000)).writeToNBT(UT.NBT.make(NBT_COLOR, DYE_INT_LightBlue, NBT_PAINTED, T), NBT_TANK), T, T);
                            break;
                        case 2:
                            aData.set(6 + i, 1, 1 + j, SIDE_UNKNOWN, 32056, new FluidTankGT(FL.Helium.make(8000)).writeToNBT(UT.NBT.make(NBT_COLOR, DYE_INT_Yellow, NBT_PAINTED, T), NBT_TANK), T, T);
                            break;
                    }
                }
            }
        }
    }
    IPrefixBlock[] tMetalCrates = { BlocksGT.crateGtDust, BlocksGT.crateGtDust, BlocksGT.crateGtIngot, BlocksGT.crateGtIngot, BlocksGT.crateGtIngot, BlocksGT.crateGtIngot, BlocksGT.crateGtPlate, BlocksGT.crateGtPlate, BlocksGT.crateGt64Dust, BlocksGT.crateGt64Plate, BlocksGT.crateGt64Ingot, BlocksGT.crateGt64Ingot };
    int[] tStart = { 1, 12 }, tEnd = { 3, 14 };
    for (int a = 0; a < 2; a++) for (int b = 0; b < 2; b++) {
        switch(aData.next(7 + (MD.HEX.mLoaded ? 1 : 0) + (MD.TC.mLoaded ? 1 : 0))) {
            case 0:
                for (int i = tStart[a]; i <= tEnd[a]; i++) for (int j = tStart[b]; j <= tEnd[b]; j++) {
                    if (aData.next3in4()) {
                        aData.set(tMetalCrates, i, 1, j, sMetals);
                        if (aData.next2in3()) {
                            aData.set(tMetalCrates, i, 2, j, sMetals);
                            if (aData.next1in2()) {
                                aData.set(tMetalCrates, i, 3, j, sMetals);
                                if (aData.next1in3())
                                    aData.ingots_or_plates(i, 4, j, 0, sMetals);
                            } else if (aData.next1in3())
                                aData.ingots_or_plates(i, 3, j, 0, sMetals);
                        } else if (aData.next1in3())
                            aData.ingots_or_plates(i, 2, j, 0, sMetals);
                    } else if (aData.next1in3())
                        aData.ingots_or_plates(i, 1, j, 0, sMetals);
                }
                break;
            case 1:
                for (int i = tStart[a]; i <= tEnd[a]; i++) for (int j = tStart[b]; j <= tEnd[b]; j++) {
                    if (aData.next3in4()) {
                        aData.set(aData.next1in2() ? BlocksGT.crateGt64Dust : BlocksGT.crateGtDust, i, 1, j, sDusts);
                        if (aData.next2in3()) {
                            aData.set(aData.next1in3() ? BlocksGT.crateGt64Dust : BlocksGT.crateGtDust, i, 2, j, sDusts);
                            if (aData.next1in2()) {
                                aData.set(aData.next1in4() ? BlocksGT.crateGt64Dust : BlocksGT.crateGtDust, i, 3, j, sDusts);
                            }
                        }
                    }
                }
                break;
            case 2:
                for (int i = tStart[a]; i <= tEnd[a]; i++) for (int j = tStart[b]; j <= tEnd[b]; j++) {
                    if (aData.next3in4()) {
                        aData.set(aData.next1in4() ? BlocksGT.crateGt64Gem : BlocksGT.crateGtGem, i, 1, j, sGems);
                        if (aData.next2in3()) {
                            aData.set(aData.next1in6() ? BlocksGT.crateGt64Gem : BlocksGT.crateGtGem, i, 2, j, sGems);
                            if (aData.next1in2()) {
                                aData.set(aData.next1in8() ? BlocksGT.crateGt64Gem : BlocksGT.crateGtGem, i, 3, j, sGems);
                            }
                        }
                    }
                }
                break;
            case 3:
                for (int i = tStart[a]; i <= tEnd[a]; i++) for (int j = tStart[b]; j <= tEnd[b]; j++) {
                    if (aData.next3in4()) {
                        aData.set(BlocksGT.crateGt64Plate, i, 1, j, sWoods);
                        if (aData.next2in3()) {
                            aData.set(BlocksGT.crateGt64Plate, i, 2, j, sWoods);
                            if (aData.next1in2()) {
                                aData.set(BlocksGT.crateGt64Plate, i, 3, j, sWoods);
                            }
                        }
                    }
                }
                break;
            case 4:
                for (int i = tStart[a]; i <= tEnd[a]; i++) for (int j = tStart[b]; j <= tEnd[b]; j++) {
                    if (aData.next3in4()) {
                        aData.set(aData.next1in2() ? BlocksGT.crateGt64Raw : BlocksGT.crateGtRaw, i, 1, j, sOres);
                        if (aData.next2in3()) {
                            aData.set(aData.next1in3() ? BlocksGT.crateGt64Raw : BlocksGT.crateGtRaw, i, 2, j, sOres);
                            if (aData.next1in2()) {
                                aData.set(aData.next1in4() ? BlocksGT.crateGt64Raw : BlocksGT.crateGtRaw, i, 3, j, sOres);
                                if (aData.next1in4())
                                    aData.set(BlocksGT.blockRaw, i, 4, j, sOres);
                            } else if (aData.next1in4())
                                aData.set(BlocksGT.blockRaw, i, 3, j, sOres);
                        } else if (aData.next1in4())
                            aData.set(BlocksGT.blockRaw, i, 2, j, sOres);
                    } else if (aData.next1in4())
                        aData.set(BlocksGT.blockRaw, i, 1, j, sOres);
                }
                break;
            case 5:
                if (MD.HEX.mLoaded)
                    for (int i = tStart[a]; i <= tEnd[a]; i++) for (int j = tStart[b]; j <= tEnd[b]; j++) {
                        if (aData.next1in2()) {
                            aData.set(aData.next1in2() ? BlocksGT.crateGt64Gem : BlocksGT.crateGtGem, i, 1, j, sHexoriums);
                            if (aData.next1in2()) {
                                aData.set(aData.next1in3() ? BlocksGT.crateGt64Gem : BlocksGT.crateGtGem, i, 2, j, sHexoriums);
                                if (aData.next1in2()) {
                                    aData.set(aData.next1in4() ? BlocksGT.crateGt64Gem : BlocksGT.crateGtGem, i, 3, j, sHexoriums);
                                    if (aData.next1in2())
                                        aData.set(i, 4, j, tHexoriumColor, 1, tHexoriumRandom, 1);
                                } else if (aData.next1in2())
                                    aData.set(i, 3, j, tHexoriumColor, 1, tHexoriumRandom, 1);
                            } else if (aData.next1in2())
                                aData.set(i, 2, j, tHexoriumColor, 1, tHexoriumRandom, 1);
                        } else if (aData.next1in2())
                            aData.set(i, 1, j, tHexoriumColor, 1, tHexoriumRandom, 1);
                    }
                break;
            case 6:
                if (MD.TC.mLoaded)
                    for (int i = tStart[a]; i <= tEnd[a]; i++) for (int j = tStart[b]; j <= tEnd[b]; j++) {
                        if (aData.next1in2()) {
                            aData.set(aData.next1in4() ? BlocksGT.crateGt64Gem : BlocksGT.crateGtGem, i, 1, j, sInfused);
                            if (aData.next1in2()) {
                                aData.set(aData.next1in6() ? BlocksGT.crateGt64Gem : BlocksGT.crateGtGem, i, 2, j, sInfused);
                                if (aData.next1in2()) {
                                    aData.set(aData.next1in8() ? BlocksGT.crateGt64Gem : BlocksGT.crateGtGem, i, 3, j, sInfused);
                                    if (aData.next1in2())
                                        aData.set(i, 4, j, tInfusedCrystal, aData.next(7));
                                } else if (aData.next1in2())
                                    aData.set(i, 3, j, tInfusedCrystal, aData.next(7));
                            } else if (aData.next1in2())
                                aData.set(i, 2, j, tInfusedCrystal, aData.next(7));
                        } else if (aData.next1in2())
                            aData.set(i, 1, j, tInfusedCrystal, aData.next(7));
                    }
                break;
            default:
                // Nothing
                break;
        }
    }
    return T;
}
Also used : FluidTankGT(gregapi.fluid.FluidTankGT) IPrefixBlock(gregapi.block.IPrefixBlock) Block(net.minecraft.block.Block) IPrefixBlock(gregapi.block.IPrefixBlock)

Aggregations

IPrefixBlock (gregapi.block.IPrefixBlock)2 Block (net.minecraft.block.Block)2 FluidTankGT (gregapi.fluid.FluidTankGT)1 BlockSilverfish (net.minecraft.block.BlockSilverfish)1 ITileEntityProvider (net.minecraft.block.ITileEntityProvider)1 ItemStack (net.minecraft.item.ItemStack)1