Search in sources :

Example 1 with TileEntitySilo

use of blusunrize.immersiveengineering.common.blocks.metal.TileEntitySilo in project ImmersiveEngineering by BluSunrize.

the class MultiblockSilo method createStructure.

@Override
public boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player) {
    EnumFacing f = EnumFacing.fromAngle(player.rotationYaw);
    pos = pos.offset(f);
    if (!(Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood")))
        for (int i = 0; i < 6; i++) if (Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood")) {
            pos = pos.add(0, -i, 0);
            break;
        }
    for (int h = 0; h <= 6; h++) for (int xx = -1; xx <= 1; xx++) for (int zz = -1; zz <= 1; zz++) if (h == 0) {
        if (Math.abs(xx) == 1 && Math.abs(zz) == 1) {
            if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "fenceTreatedWood"))
                return false;
        } else if (xx == 0 && zz == 0)
            if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
                return false;
    } else {
        if (h < 6 && xx == 0 && zz == 0) {
            if (!world.isAirBlock(pos.add(xx, h, zz)))
                return false;
        } else if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
            return false;
    }
    for (int h = 0; h <= 6; h++) for (int l = -1; l <= 1; l++) for (int w = -1; w <= 1; w++) {
        if (h == 0 && !((l == 0 && w == 0) || (Math.abs(l) == 1 && Math.abs(w) == 1)))
            continue;
        if (h > 0 && h < 6 && l == 0 && w == 0)
            continue;
        int xx = f == EnumFacing.EAST ? l : f == EnumFacing.WEST ? -l : f == EnumFacing.NORTH ? -w : w;
        int zz = f == EnumFacing.NORTH ? l : f == EnumFacing.SOUTH ? -l : f == EnumFacing.EAST ? w : -w;
        world.setBlockState(pos.add(xx, h, zz), IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.SILO.getMeta()));
        BlockPos pos2 = pos.add(xx, h, zz);
        TileEntity curr = world.getTileEntity(pos2);
        if (curr instanceof TileEntitySilo) {
            TileEntitySilo currTank = (TileEntitySilo) curr;
            currTank.offset = new int[] { xx, h, zz };
            currTank.pos = h * 9 + (l + 1) * 3 + (w + 1);
            currTank.facing = f.getOpposite();
            currTank.formed = true;
            currTank.offset = new int[] { xx, h, zz };
            currTank.markDirty();
            world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
        }
    }
    player.addStat(IEAchievements.mbSilo);
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntitySilo(blusunrize.immersiveengineering.common.blocks.metal.TileEntitySilo) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

TileEntitySilo (blusunrize.immersiveengineering.common.blocks.metal.TileEntitySilo)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1